怎样在加个条件,如年龄最大那个

深圳pb 2012-07-20 12:24:31
怎样在加个条件,如年龄最大那个
...全文
254 12 打赏 收藏 转发到动态 举报
写回复
用AI写文章
12 条回复
切换为时间正序
请发表友善的回复…
发表回复
walkman_22 2012-08-07
  • 打赏
  • 举报
回复
楼主问题真简洁
l4kangaxx 2012-07-27
  • 打赏
  • 举报
回复
select * from tb t where 年龄=(select max(年龄) from tb where id=t.id)
应该是正解
--小F-- 2012-07-20
  • 打赏
  • 举报
回复
是分组求最大还是单个求最大?

如果是分组的话:
select * from tb t where 年龄=(select max(年龄) from tb where id=t.id)
叶子 2012-07-20
  • 打赏
  • 举报
回复
单纯的年龄最大,树哥正解!!
百年树人 2012-07-20
  • 打赏
  • 举报
回复
select top 1 * from tb order by 年龄 desc
--or
select * from tb where 年龄=(select max(年龄) from tb)
天-笑 2012-07-20
  • 打赏
  • 举报
回复
方法较多,需楼主给出具体数据
以学习为目的 2012-07-20
  • 打赏
  • 举报
回复

--楼主 问题够精炼

select top 1 * from tb order by 年龄 desc


--or


select * from tb t where 年龄=(select max(年龄) from tb where id=t.id)
gogodiy 2012-07-20
  • 打赏
  • 举报
回复
原始代码给出来先

34,575

社区成员

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

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