开发者

Trying to get top 20 mySQL

Trying to find: Show the top-20 PIs who have the largest total amount of awards along with the universities they are affliated with.

Mysql开发者_JAVA百科

SELECT max(award), pi, org 
FROM iis 
LIMIT 20; 

This only gives me and I want the top 20 records:

Trying to get top 20 mySQL

Table

Trying to get top 20 mySQL

Anyone??


If the awards are not already totaled, then you want to find the sum of the awards for each PI, you need to use SUM, and GROUP BY pi, to sum the awards for each PI

SELECT SUM(award) AS totalAwards, pi, org 
FROM iis 
GROUP BY pi, org
ORDER BY SUM(award) DESC
LIMIT 20;


SELECT award, pi, org 
FROM iis
ORDER BY award DESC
LIMIT 20; 
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜