AsCENT & MaNGOS
Would you like to react to this message? Create an account in a few clicks or log in to continue.

[MySQL] RANKING

Go down

[MySQL] RANKING Empty [MySQL] RANKING

¿Ã¸®±â by Admin 2009-10-31, 4:57 am

CREATE TABLE shop (
id INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
food VARCHAR(32),
gold DECIMAL,
point int(5)
);

INSERT INTO shop
VALUES (NULL, 'apple', 12.75, 10), (NULL, 'orange', 1.89, 3), (NULL, 'pear', 19.23, 6)
, (NULL, 'banana', 4.25, 7), (NULL, 'cherry', 12.75, 2), (NULL, 'plum', 23.15, 5);

SET @rank=0;

SELECT @rank:=@rank+1 AS rank, food, gold, point
FROM shop
ORDER BY gold DESC, point DESC
;

Admin
Admin

°Ô½Ã¹° °¹¼ö : 380
Age : 54
Registration date : 2008-08-09

Character sheet
test:

https://study4u.forumkorean.com

À§·Î Go down

[MySQL] RANKING Empty Re: [MySQL] RANKING

¿Ã¸®±â by Admin 2009-10-31, 5:01 am

[°á°ú]
+------+---------+------+-------+
| rank | food | gold | point |
+------+---------+------+-------+
| 1 | plum | 23 | 5 |
| 2 | pear | 19 | 6 |
| 3 | apple | 13 | 10 |
| 4 | cherry | 13 | 2 |

| 5 | banana | 4 | 7 |
| 6 | orange | 2 | 3 |
+------+---------+------+-------+
6 rows in set

Admin
Admin

°Ô½Ã¹° °¹¼ö : 380
Age : 54
Registration date : 2008-08-09

Character sheet
test:

https://study4u.forumkorean.com

À§·Î Go down

À§·Î

- Similar topics

 
Permissions in this forum:
´ä±ÛÀ» ¿Ã¸± ¼ö ¾ø½À´Ï´Ù