奥运奖牌的mysql查询问题

时间:2012-07-12 09:27:49

标签: mysql

我在mysql olympic中有一个表,字段名是

country varchar, gold(int), silver(int), bronze(int)

请帮助我查询,以便按照奥运奖牌列表的顺序排列数据。

3 个答案:

答案 0 :(得分:4)

SELECT *
FROM `olympic`
ORDER BY `gold` DESC, `silver` DESC, `bronze` DESC;

答案 1 :(得分:1)

试试这个:

select 
country, 
Sum(gold) as gold, 
Sum(silver) as silver,
Sum(bronze) as bronze
from olympic 
group by country 
order by 
gold desc, silver desc, bronze desc

这将为您提供他们已获得奖牌的国家列表。

答案 2 :(得分:0)

SELECT country, gold, silver, bronze
FROM olympic
ORDER BY gold DESC, silver DESC, bronze DESC;