現在有個表,里面有個字段:PEOPLE   而且這個PEOPLE中會有重復的數據,我現在想知道如何查詢這個表中有多少不重復的PEOPLE,怎么把這些PEOPLE的數據提取出來。多謝大家!!!

解决方案 »

  1.   


    select count(1) as total from tablename group by people having count(1) =1;
      

  2.   

    select count(distinct people) as total from tablename;
      

  3.   

    哈哈,我这是查重复的
    select count(1) as total from tablename group by people having count(1)>1;
      

  4.   

    晕:
    select people from tablename group by people having count(1) = 1;
      

  5.   

    select * from tablename where exists(select `id`,count(1) as total from tablename group by people having count(1) =1);
      

  6.   

    看了大家的回復,我本來是打算先找出不重復的(count(1)=1)
    然后再找出重復的( count(1)>1)
    有沒有更好的辦法?
      

  7.   

    不重复的select count(1) as total from tablename group by people having count(1) =1;重复的select count(1) as total from tablename group by people having count(1) >1;
      

  8.   

    我是這么一段時間內重復的寫的
    大伙幫我看看  那里不對
    select people from tablename where exists(select count(1) as total from tablename group by people having count(1)=1 and time between '$time1' and '$time2')
    請大家幫幫忙亂 謝謝