常用的sql

数据重复了,只需要其中一条

— id 重复了,取出其中一条
SELECT id,member_seq,point,gmt_create FROM XXXX WHERE              and gmt_create > “2020-07-20 00:00:00”     and gmt_create < “2020-07-26 23:59:59”     AND point > 0
GROUP BY id,member_seq,point,gmt_create — id 重复了,取出其中一条     数据没有重复,取出最早的一条数据 — 从最新的数据中取出 制作中的数据 SELECT id,user_id,material_id,status FROM (   – https://blog.csdn.net/qq_37111953/article/details/80916820   – 取出每个用户最新的一条用户物料数据   select a.id,a.user_id,a.material_id,a.status   from (       select * from
xxxxxx       where activity_id = n and ds = 20100622   ) a   left join (       select * from 
xxxxxx       where activity_id = n and ds = 20100622   ) b   on a.user_id=b.user_id and a.gmt_create<b.gmt_create   group by a.id,a.user_id,a.material_id,a.status   having count(b.id)<1   – 取出每个用户最新的一条用户物料数据 )as last_record_all where status = 1 — 从最新的数据中取出 制作中的数据