sql语句小问题求教,,在线等,利马揭帖!50!

crystal1024 2005-03-29 10:10:48
id name group1 score
1 aa 1 90
2 bb 1 84
3 bb 2 50
4 dd 2 30
5 cc 3 60
求每个组中分数最大的行信息,结果要这样:
1 aa 1 90
2 bb 2 50
3 cc 3 60

我这个菜啊...唉..!
...全文
97 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
风河 2005-03-29
  • 打赏
  • 举报
回复
select id,name,group1,max(score)as maxscore from tbl_score group by group1
  • 打赏
  • 举报
回复
学习...
jinjazz 2005-03-29
  • 打赏
  • 举报
回复
select * from xx a where not exists
(select 1 from xx where group=a.group and score>a.score)
crystal1024 2005-03-29
  • 打赏
  • 举报
回复
select a.*
from xx a
inner join
(select group1,max(score) score1
from xx
group by group1) b
on a.group1 = b.group1
and a.score = b.score1
order by id
啊.想到了.抱歉各位!

5,388

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 开发及应用
社区管理员
  • VCL组件开发及应用社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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