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 ;

 

posted @ 2016-05-25 13:47  小安妮的熊  Views(198)  Comments(0Edit  收藏  举报