分组求最大日期

gaobinbinbin 2012-03-17 08:33:44
按客户编号分组取最大时间
...全文
51 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
  • 打赏
  • 举报
回复
select *from table a where 日期=(select max(date) from table b where a.id=b.id)
  • 打赏
  • 举报
回复
select *from(select row_number()over(partition by 客户编号 order by 日期) as number,* from table)a where number=1

22,209

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server 疑难问题
社区管理员
  • 疑难问题社区
  • 尘觉
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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