语句你也会写

永远- 2005-06-16 04:19:11
表里有个 name(varchar) ,updatetime(DateTime).
我想得到最近的一条更新的记录name,以updatatime为条件,怎么写?
...全文
122 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
jixiaojie 2005-06-17
  • 打赏
  • 举报
回复
select * from tb where updatetime =(select max(updatetime) from tb)

如果在最近更新时间相同的情况下,可以返回多条记录
奔跑9999 2005-06-17
  • 打赏
  • 举报
回复
select top 1 name from 表 order by updatetime desc
select * from tb where updatetime =(select max(updatetime) from tb)
都可以
lsxaa 2005-06-16
  • 打赏
  • 举报
回复
select top 1 name from 表 order by updatetime desc

27,579

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server 应用实例
社区管理员
  • 应用实例社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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