大家请进!谢谢!

pzrr_00 2005-08-15 07:43:49
现有一问题,实在是捆扰了我好久了~
表table:(a,b,c)
比如select max(a) from table group by c
但是在这里我想相应获得对应这些按C分组后最大的a对应的b,该如何写?请指教!谢谢!
...全文
112 4 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
wgsasd311 2005-08-15
  • 打赏
  • 举报
回复
假如表为test1:
select b from test1 where a in(select max(a) from test1 group by c)
mschen 2005-08-15
  • 打赏
  • 举报
回复
select b
from 表 a
join
(
select c
,max(a) as max_a
from 表
group by c
) t on a.c=t.c and a.a=max_a
mschen 2005-08-15
  • 打赏
  • 举报
回复
select b

from 表 t

where a=(select max(a) from 表 where c=t.c)
spring_504 2005-08-15
  • 打赏
  • 举报
回复
select b from table where a+c in (select max(a)+c from table group by c)

27,582

社区成员

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

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