select a from table group by a having count(*)=1

解决方案 »

  1.   

    Select * From TableName A Where Not Exists(Select 1 From TableName Where A=A.A Group By A Having Count(*)>1)
      

  2.   

    Create Table TEST
    (A Char(2),   
     B Char(2),
     C Char(2))
    Insert TEST Select 'a1',  'b1',  'c1'
    Union  All Select 'a2',  'b1',  'c1'
    Union  All Select 'a2',  'b1',  'c1'
    Union  All Select 'a3',  'b2',  'c1'
    Union  All Select 'a4',  'b2',  'c2'
    GO
    Select * From TEST A Where Not Exists(Select 1 From TEST Where A=A.A Group By A Having Count(*)>1)
    GO
    Drop Table TEST
    --Result
    /*
    A B C
    a1 b1 c1
    a3 b2 c1
    a4 b2 c2
    */
      

  3.   

    select a from table group by a having count(1)=1