SQL 如何获取时间最新的记录
2018-02-02 11:03
267 查看
-- 方法1 select a.* from table1 a where not exists(select 1 from table1 b where b.name=a.name and b.gdtime>a.gdtime) -- 方法2 select a.* from table1 a inner join (select name, max(gdtime) 'maxgdtime' from table1 group by name) b on a.name=b.name and a.gdtime=b.maxgdtime
相关文章推荐
- 如何用SQL查询语句获取Oracle表 树形结构的记录(PL/SQL )
- sql查询数据库时间最新的一条记录
- 根据时间获取最新数据 SQL(每一个人或者每一项)
- MS SQLSERVER中如何快速获取表的记录总数
- SQL获取表中最新插入的记录
- 如何获取sql数据中时间的月份、年份(类型date)
- mysql根据某个字段分组根据更新时间获取最新的记录
- sql表中如何获得最大时间的记录
- MS SQLSERVER中如何快速获取表的记录总数
- mysql如何记录sql执行时间
- MS SQLSERVER中如何快速获取表的记录总数
- MS SQLSERVER中如何快速获取表的记录总数
- SQL中如何获取记录的排名
- 一条sql获取每个类别最新的一条记录
- sqlplus查询数据中的最新一条,表中有记录时间的字段
- MS SQLSERVER中如何快速获取表的记录总数
- 如何获取SQLite最新版本及SQLite数据库中的SQL语句解说
- sql筛选出每一人的时间最新的一条记录
- Oracle获取最新时间记录与上行差值案例
- 如何通过SQL语句获取分组中的某几条记录