SQL 获取表中最新数据并过滤重复项

来源:互联网 发布:nginx 泛域名配置 编辑:程序博客网 时间:2024/05/16 17:26

背景是 监护仪器会往这张表里面不断插入数据,同一秒中可能有很多 重复数据,需过滤每种数据的最新一笔数据

采用 取自增列 ID最大的不同数据

select * from 表名 as t

where not exists (select  * from 表名 where t.ItemNo=ItemNo and t.ID<ID )


上图 和查询全部 数据 order by  时间 desc, id desc   做个对比   取不重复 且ID 最大的 一套数据

0 0