1 /*--分组*/ 2 SELECT 3 InvitedPerson,COUNT(*) 4 FROM 5 dyhl_clue group by InvitedPerson,DearShipID 6 7 /*排序*/ 8 SELECT t.* FROM (SELECT * FROM dyhl_clue ORDER BY ShareStartTime) t GROUP BY DearShipID 9 /* 10 按照客户ID、店头ID进行分组,每组(每个店的第一个人)的信息读取出来。---这个集合(合格数据集合) 就是非重复线索数据 集合 重复数据集合 线索状态改为2 11 把合格数据集合里所有的宾客全部标为 平台推送标志 =1 12 合格数据集合的总数减宾客的个数,就是每个店的访客线索的个数 设置一个参数 X% 向上取整 或者向下取整 取到的数据 平台推送为1 13 相当于 SQL 里的 TOP LIMIT 1*/ 14 select * from dyhl_clue where DearShipID >=0 group by InvitedPerson, DearShipID 15 order by ShareStartTime desc; 16 17 select * from t_info 18 19 select * from dyhl_user group by role_id 20 21 select max(t.id) from ( 22 select e.* from dyhl_user e order by e.mobile 23 ) t group by t.role_id