这个SQL语句如何写?

oldsky 2003-10-29 04:44:09
A# B#
1 1
1 2
1 3
2 1
2 2
2 4
查出A#=2且在A#该组中B#最大的记录
...全文
34 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
zarge 2003-10-29
  • 打赏
  • 举报
回复
select A#, max(B#) from 表 where A# = 2
zjcxc 元老 2003-10-29
  • 打赏
  • 举报
回复
select * from 表
where [a#]=2 and [b#]=(select max([b#]) from 表 where a#=2)
海盗2019 2003-10-29
  • 打赏
  • 举报
回复
select * from tb_nm t, (select max(B#) b from tb_nm where A#=2) m where t.A#=2 and t.#= m.b;
dwhhh 2003-10-29
  • 打赏
  • 举报
回复
select * from table where b#=(select max(b#) from table where a#=2) and a#=2
pengdali 2003-10-29
  • 打赏
  • 举报
回复
select top 1 * from 表 where a#=2 order by b# desc

34,590

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server相关内容讨论专区
社区管理员
  • 基础类社区
  • 二月十六
  • 卖水果的net
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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