查询一个表的一条记录

天涯海角的人 2007-08-13 11:05:12
我想查询一分组记录的全部记录;
比如:select max(score) from students group by name;
这只能查出max(score)的值,但我想查询此记录的其他字段的值,请问该如何做?
...全文
260 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
kinglht 2007-09-05
  • 打赏
  • 举报
回复
select * from students
where (name,score) in
(select name,max(score)
from students
group by name)
devise 2007-09-05
  • 打赏
  • 举报
回复
select a.* from students a,
(select name,max(score) score from students group by name) b
where a.name=b.name and a.score=b.score;

select * from students
where (name,score) in (select name,max(score) from students group by name);

devise 2007-09-05
  • 打赏
  • 举报
回复
select a.* from students a,
(select name,max(score) score from students group by name) b
where a.name=b.name and a.score=b.score;

ksrs 2007-08-28
  • 打赏
  • 举报
回复
select * from students
where (name,score) in
(select name,max(score)
from students
group by name)
tangjiyu 2007-08-17
  • 打赏
  • 举报
回复
修正
select * /* 多了一个列rk,去掉就列出详细列名 */ from
(select rank() over (partition by name order by score desc) as rk,t.* from students t)
where rk=1;
tangjiyu 2007-08-17
  • 打赏
  • 举报
回复
select * /* 多了一个列rk,去掉就列出详细列名 */ from
(select rank() over (partition by name order by score ) as rk,t.* from students t)
where rk=1;
子陌红尘 2007-08-13
  • 打赏
  • 举报
回复
select s.* from students s where not exists(select 1 from students where name=s.name and score>s.score)

select s.* from students s,(select name,max(score) as score from students group by name) v where s.name=b.name and s.score=v.score

3,492

社区成员

发帖
与我相关
我的任务
社区描述
Oracle 高级技术相关讨论专区
社区管理员
  • 高级技术社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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