2019-03-01
閱讀量:
1203
sql語句分組取前五名
問題描述:

mysql數(shù)據(jù)庫字段如上圖所示
按stage_id分組后,按照total由大到小遞減取得前5條,
現(xiàn)在每一組有30條,總共有8組
解決方法:
select * from table as a where (select count(distinct(total)) from table as b where a.stage_id = b.stage_id and b.total > a.total) < 5;






評(píng)論(0)


暫無數(shù)據(jù)
CDA考試動(dòng)態(tài)
CDA報(bào)考指南
推薦帖子
0條評(píng)論
0條評(píng)論
0條評(píng)論
0條評(píng)論