# 求SQL！

lb06008401 2013-02-22 01:54:43

xuehao xingming kemu fenshu
1 小李 语文 60
1 小李 数学 70
1 小李 英语 80
2 小王 语文 80
2 小王 数学 50
2 小王 英语 60

xingming kemu fenshu

xingming kemu fenshu

...全文
1583 5 点赞 打赏 收藏 举报

5 条回复

lb06008401 2013-02-22

xingming kemu fenshu 1:select * from tba as a where fenshu=(select max(fenshu) where tba where a.xingming=xingming) 2:select * from tba as a where fenshu=(select max(fenshu) where tba where a.kemu……
1.select * from A as t where t.fenshu=(select max(fenshu) from mr_test where t.xingming=xingming) 2.select * from A as t where t.fenshu=(select max(fenshu) from mr_test where t.kemu=kemu) 3.select * from A t where t.fenshu=( select max(fenshu) from A b where t.xingming=xingming and fenshu<(select max(fenshu) from mr_test where b.xingming=xingming)) 谢谢！这个就可以啦！
• 打赏
• 举报

• 打赏
• 举报

szm341 2013-02-22
xingming kemu fenshu 1:select * from tba as a where fenshu=(select max(fenshu) where tba where a.xingming=xingming) 2:select * from tba as a where fenshu=(select max(fenshu) where tba where a.kemu=kemu) 3:select * from tba as a where fenshu=(select max(fenshu) where tba b where a.xingming=xingming and fenshu< (select max(fenshu) from tba where b.xingming=xingming) )
• 打赏
• 举报

• 打赏
• 举报

select xingming,kemu,fenshu=max(fenshu) from A group by xingming,kemu
• 打赏
• 举报

2.7w+

MS-SQL Server 应用实例

2013-02-22 01:54