重庆分公司,新征程启航

为企业提供网站建设、域名注册、服务器等服务

mysql怎么算出前三名 mysql取前三

Mysql 分组以后取每组的前三名数据

Try this one,should be fine

成都一家集口碑和实力的网站建设服务商,拥有专业的企业建站团队和靠谱的建站技术,十载企业及个人网站建设经验 ,为成都超过千家客户提供网页设计制作,网站开发,企业网站制作建设等服务,包括成都营销型网站建设,成都品牌网站建设,同时也为不同行业的客户提供做网站、网站设计的服务,包括成都电商型网站制作建设,装修行业网站制作建设,传统机械行业网站建设,传统农业行业网站制作建设。在成都做网站,选网站制作建设服务商就选成都创新互联公司

下面这个已经有排序了哦,不行么?

SELECT uid, group_concat(subject)

FROM (SELECT id, uid, subject

FROM (SELECT id, uid, subject,

(SELECT COUNT(*)

FROM t_subject

WHERE uid = t.uid

AND subject = t.subject) RK

FROM t_subject t) t1

WHERE rk = 3) t2

GROUP BY uid

多了个a.原来

或者你直接用个substring()得了。。。

大神进:MYSQL各科成绩前三名

select * from

(select Student.S#,Sname,Sage,Ssex,SC.C#,score,Cname

from SC inner join Student on SC.S#=Student.S#

inner join Course on Course.C#=SC.C#) as t

where exists(

select count(1) from t as d

where C#=d.C# and score d.score

having count(1)3

)

Mysql 单表查询各班级总分前三名

select class,total,name from (select *,ywsc+sxsc as total from st ORDER BY total DESC) b

where

not EXISTS(select * from (select *,ywsc+sxsc as total from st ORDER BY total DESC) c where c.class=b.class and b.total c.total GROUP BY c.class HAVING COUNT(*)2 )

ORDER BY b.class,b.total DESC

mysql版 查询各科成绩前三名的记录:(不考虑成绩并列情况)

上面那条答案应该是可以的啊,可能是看起来复杂了点吧,我自己试过是没问题的:

SELECT t1.sno,t1.cno,Score

FROM SC t1

WHERE EXISTS

(SELECT COUNT(1)

FROM SC

WHERE t1.cno= cno AND t1.scorescore

HAVING COUNT(1)3)

ORDER BY t1.cno,score DESC

另外还有一种类似的写法:

SELECT t1.sno,t1.cno,Score

FROM SC t1

WHERE

(SELECT COUNT(cno)

FROM SC

WHERE t1.cno= cno AND t1.scorescore)3

ORDER BY t1.cno,score DESC


网页名称:mysql怎么算出前三名 mysql取前三
标题链接:http://cqcxhl.cn/article/dogesej.html

其他资讯

在线咨询
服务热线
服务热线:028-86922220
TOP