大家好,帮我看看这个问题,多谢!

tlc2003 2003-11-11 04:40:07
数据库中一个表:
A B C
* * *
* * *
....

偶想知道我得到max(A),max(B)并且同时得到他们各自相对应的(max(A),max(B)对应的)C的值,也就是说得到max(A) c max(A)对应的) max(B) c(max(A)对应的)
* * * *

该怎么写语句?多谢!!!
...全文
25 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
zjcxc 元老 2003-11-11
  • 打赏
  • 举报
回复
select max(A)
,[max(A)对应C的值]=(select top 1 c from 表 where A=(select max(A) from 表))
,max(B)
,[max(B)对应C的值]=(select top 1 c from 表 where B=(select max(B) from 表))
from 表
shuiniu 2003-11-11
  • 打赏
  • 举报
回复
select * from 表 where a=(select max(a) from 表) or b=(select max(b) from 表)
??
shuiniu 2003-11-11
  • 打赏
  • 举报
回复
select c max(A),max(b)
from 表
group by c
??
wzh1215 2003-11-11
  • 打赏
  • 举报
回复
select max(A),C from 表 group by C
union all
select max(B),C from 表 group by C
txlicenhe 2003-11-11
  • 打赏
  • 举报
回复
Select Max(A),(Select c from 表 where A = aa.A) as cmaxA,
max(B),(Select c from 表 where B = aa.B) as cmaxB
from 表 aa


pengdali 2003-11-11
  • 打赏
  • 举报
回复
select * from 表 where a=(select max(a) from 表) or b=(select max(b) from 表)

34,499

社区成员

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

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