select distinct name,personid from test group by name

解决方案 »

  1.   

    select  name ,personid from table where personid in {12,14,16,18} 
    group by personid
      

  2.   

    select distinct name,personid from test order by personid
    where personid < 20 and  persionid %2= 0 
      

  3.   

    各位,所谓的身份证号码,是我随便举的例子,我并不是用distinct找出所有的数据,也不是根据身份证的号码大小来判断那只是一个随便写的例子,我要的出的是,找出所有在不同部门出现过的人的信息,只在一个部门出现的不要
      

  4.   

    试试这个:
    select name,personid from test group by (name,personid,bumen) having count(*)>1
      

  5.   

    select  name ,personid from table
    group by personid,name
    having count(bumen) > 1
    这样,就会剔除那些只在一个部门出现的人的信息了。
      

  6.   

    select distinct name,personid from test where count(name)>1
      

  7.   

    select name,personid from test group by name,personid  having count(*)>1;
    这个吧?