1. 程式人生 > >去除重複語句SQL

去除重複語句SQL

表 table1
欄位, a ,b,c,d,e

查詢出那個e欄位有多個,並且a欄位都為F

select a,e from table1 group by a,e having  a = 'F' and count(e)>1;

結果:

a          e
F          55

去除重複欄位

select * from table1 where e in (select e from table1 group by e having  count(*)>1);

結果

a      b      c     d      e
F      null   1
2 55