有点晕了,大侠来帮我写这个SQL吧

flashroom 2004-08-26 02:19:58
id team dotime
1 1 2004-4-4
2 2 2004-5-8
3 2 2004-8-9
4 1 2004-1-5
5 2 2004-5-9
6 1 2006-5-4

写条SQL得出每组中 DOTIME最大的ID。
结果应该是

id
6
3

帮帮忙啦,多谢


...全文
102 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
zsforever 2004-08-26
  • 打赏
  • 举报
回复
select id , team , dotime from yourtable a where a.dotime = (select max(dotime) from yourtable b where a.team=b.team )
flashroom 2004-08-26
  • 打赏
  • 举报
回复
多写楼上的
zjcxc 元老 2004-08-26
  • 打赏
  • 举报
回复
select id=max(id),b.team
from 表 a,(select team,dotime=max(dotime) from 表 group by team)b
where a.team=b.team and a.dotime=b.dotime
group by b.team
flashroom 2004-08-26
  • 打赏
  • 举报
回复
int int datetime

不好意思,忘了,呵呵
yesterday2000 2004-08-26
  • 打赏
  • 举报
回复
select id
from tb a,(select team,max(dotime) as dotime from tb group by team) b
where a.team=b.team
dnel 2004-08-26
  • 打赏
  • 举报
回复
DOTIME的类型是什么啊

34,576

社区成员

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

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