按 gpcode每组 取每组 f4 最大的那条记录: 方法一: select * from calcgsdataflash a where gscode = 'LS_F' and ymd >= 20171117 and ymd <= 20171117 and 1 >= (select count(*) from calcgsdataflash b where gscode = 'LS_F' and ymd >= 20171117 and ymd <= 20171117 and
项目需要筛选出不重复数据,以前没有做过,第一反应就是利用distinct处理,但是弄了好久也没搞出来,大家有知道的望告知下. 这次筛选没有使用distinct ,是利用group by ,利用id为唯一标示符(自增长),对按user进行排列,然后取重复项最小id(非重复项直接取唯一id),并以此id为条件查询,从而去除重复的数据. 数据格式为: 使用语句如下: select * from tbl_DPImg where ID in (select min(ID) from tbl_DPImg g