求教一个SQL语句的写法

xz8000 2003-06-13 11:06:57
求教一个SQL语句的写法:

我有一个设备异常日志表:TabLog
设备编号 异常时间 异常信息
ID LogTime LogInfo


我想查出所有设备最近一次的异常信息的SQL语句怎么写?

如:
1 2003-06-13 "AAAA"
1 2003-06-12 "BBBB"
2 2003-06-11 "CCCC"
2 2003-06-10 "DDDD"

查询结果:
1 2003-06-13 "AAAA"
2 2003-06-11 "CCCC"
...全文
29 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
xz8000 2003-06-13
  • 打赏
  • 举报
回复
谢谢你们的思路
我实现了
select a.* from tablog,(select ID,max(logtime) as MaxTime from tablog group by ID) as b where a.ID=b.ID and A.Logtime=B.Maxtime
chenyu5188 2003-06-13
  • 打赏
  • 举报
回复
同意左手的
饮水需思源 2003-06-13
  • 打赏
  • 举报
回复
select a.* from tablog,(select ID,max(logtime) from tablog) as b
where a.ID=b.ID
victorycyz 2003-06-13
  • 打赏
  • 举报
回复
select * from tablog inner join (select max(异常时间) as maxdate from tablog) as tabA on tablog.异常时间=taba.maxdate

1,216

社区成员

发帖
与我相关
我的任务
社区描述
VB 数据库(包含打印,安装,报表)
社区管理员
  • 数据库(包含打印,安装,报表)社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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