收益互换,见习黑玫瑰国语优酷,种子搜索神器2012
1.相关数据表
score表
[user]表
sql语句如下:
--查询出各科成绩最好的学生信息
--自连接
--select top 1 * from score b where b.scorename = '数学' order by b.score desc
select a.id,u.name,a.scorename,a.score
from score a,[user]u
where uid in (select top 1 uid
from score b
where b.scorename = a.scorename
order by b.score desc) and a.uid=u.id
order by a.scorename, a.score desc
查询结果如下图:
如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!!
点击进行留言回复
相关文章:
-
-
详解SQL游标的用法
类型: 1.普通游标 只有next操作 2.滚动游标 有多种操作1.普通游标declare @username varchar(20),@userid varc...
[阅读全文]
-
-
-
-
-
-
-
-
-
网友评论