mysql去重

时间:2023-12-28 20:26:56

select a.id,a.ssmz,(select count(ssmz) from shop_tourist_key b where b.ssmz=a.ssmz) as count
             from shop_tourist_key a WHERE a.ssmz is not null group by a.ssmz LIMIT 0,3;

select a.id,a.ssmz,(select count(ssmz) from shop_tourist_key b where b.ssmz=a.ssmz) as count
             from shop_tourist_key a where ISNULL(a.ssmz)=false group by a.ssmz order by count DESC
            LIMIT 0,3;

select a.id,a.ssmz,(select count(ssmz) from shop_tourist_key b where b.ssmz=a.ssmz) as count,
 count(distinct a.ssmz)  from shop_tourist_key a group by a.ssmz LIMIT 0,3 ;