请教下一条SQL语句

lunhuifengzheng 2009-06-02 10:28:30
请教下,如何查询表中的最大值,比如说一个TEST表,然后表中存储课程号(K)和成绩(C)和名字(M),请问下如何查询出每门课的最大成绩值的全部信息。用一条SQL语句。
...全文
78 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
lunhuifengzheng 2009-06-02
  • 打赏
  • 举报
回复
[Quote=引用 5 楼 ks_reny 的回复:]
引用 4 楼 lunhuifengzheng 的回复:
引用 2 楼 ks_reny 的回复:
SQL code
select * from test t where not exists(select 1 from test where k=t.k and c>t.c)


能解释下吗,小弟初学不大懂 select * from test t t是什么,还有select 1 from test where k=t.k and c>t.c

t 是别名, 这是表和自身关联的语句。
[/Qudote]

大哥能帮我解释下整条语句吗
lunhuifengzheng 2009-06-02
  • 打赏
  • 举报
回复
[Quote=引用 5 楼 ks_reny 的回复:]
引用 4 楼 lunhuifengzheng 的回复:
引用 2 楼 ks_reny 的回复:
SQL code
select * from test t where not exists(select 1 from test where k=t.k and c>t.c)


能解释下吗,小弟初学不大懂 select * from test t t是什么,还有select 1 from test where k=t.k and c>t.c

t 是别名, 这是表和自身关联的语句。
[/Quote]

谢了
ks_reny 2009-06-02
  • 打赏
  • 举报
回复
[Quote=引用 4 楼 lunhuifengzheng 的回复:]
引用 2 楼 ks_reny 的回复:
SQL code
select * from test t where not exists(select 1 from test where k=t.k and c>t.c)


能解释下吗,小弟初学不大懂 select * from test t t是什么,还有select 1 from test where k=t.k and c>t.c
[/Quote]
t 是别名, 这是表和自身关联的语句。
lunhuifengzheng 2009-06-02
  • 打赏
  • 举报
回复
[Quote=引用 2 楼 ks_reny 的回复:]
SQL code
select * from test t where not exists(select 1 from test where k=t.k and c>t.c)
[/Quote]

能解释下吗,小弟初学不大懂 select * from test t t是什么,还有select 1 from test where k=t.k and c>t.c
lunhuifengzheng 2009-06-02
  • 打赏
  • 举报
回复
按K(课程号)进行分类,而不是C,请教下。
ks_reny 2009-06-02
  • 打赏
  • 举报
回复

select * from test t where not exists(select 1 from test where k=t.k and c>t.c)
jiangshun 2009-06-02
  • 打赏
  • 举报
回复
select * from TEST where K=(select top 1 K from Test order by C)

27,579

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server 应用实例
社区管理员
  • 应用实例社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧