赞
踩
直接贴代码:(领悟看个人QAQ)
百度搜的,但是怕忘记。
一张表获取最新的一条记录:
- -- 方法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
select min(col * 1) , max(col * 1) from table;
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。