mysql去重

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 ;

原文地址:https://www.cnblogs.com/1246447850qqcom/p/5526726.html