求助2014年的宝鸡中考成绩查询2014怎么查

22:14 提问
求sql查询,找出每门功课成绩最高的学生
一个表格有三列:名字、科目、成绩, 科目中有四门功课,怎么设计查询找出每门功课中成绩 最高的那条信息
想到用group by 可是只能查询功课中最高的成绩,不能显示姓名
按赞数排序
select * from 表 where 成绩 in (select max(成绩) in 表 group by 成绩)
declare @名字 nchar(10),@成绩 smallint
@名字=名字,@成绩=max(成绩) from 表 group by 名字
select * from 表
where 表.名字 = @名字 and 表.成绩 =@成绩
select a.名字,a.科目,a.成绩 from 表2 a inner join
名字,max(成绩)as 成绩 from 表2 group by 名字) b
on a.名字 = b.名字 and a.成绩= b.成绩
select * from 表 where 成绩 in (select max(成绩) in 表 group by 科目)
select * from 表 where 科目+convert(char(5),成绩) in (select 科目+convert(char(5)+max(成绩)) in 表 group by 科目)
select * from (select 名字, 科目, 成绩, rank() over(partition by 科目 order by 成绩 desc) ranking from 表) where ranking = 1;
感谢大家献策啊,呃,这个表……我想起head in first中的一句话,设计糟糕的表应当重新设计,而不应该迁就于更复杂的查询。
select * from
student st,(select max(st.score) max_sc, st.course from student st group by st.course) res
where res.max_sc = st.score and res.course = st.course
其他相似问题}

我要回帖

更多关于 2014年中考成绩查询 的文章

更多推荐

版权声明:文章内容来源于网络,版权归原作者所有,如有侵权请点击这里与我们联系,我们将及时删除。

点击添加站长微信