SQL> Insert Into t_test Values('k','001');1 行 已插入SQL> Insert Into t_test Values('b','002');1 行 已插入SQL> Insert Into t_test Values('c','003');1 行 已插入SQL> Insert Into t_test Values('d','003');1 行 已插入SQL> Insert Into t_test Values('b','002');1 行 已插入SQL> Insert Into t_test Values('f','002');1 行 已插入SQL> select * from t_test;IDD NUM
---------- ----------
k 001
b 002
c 003
d 003
b 002
f 0026 行 已选择SQL>
SQL> Select p.idd,p.num,'是' From t_test p
2 ,(Select num, Count(1) cc From t_test Group By num) t
3 Where p.num=t.num
4 And cc>1
5 Union All
6 Select p.idd,p.num,'否' From t_test p
7 ,(Select num, Count(1) cc From t_test Group By num) t
8 Where p.num=t.num
9 And cc=1
10 ;IDD NUM '是'
---------- ---------- ----
b 002 是
b 002 是
f 002 是
c 003 是
d 003 是
k 001 否6 行 已选择SQL>
---------- ----------
k 001
b 002
c 003
d 003
b 002
f 0026 行 已选择SQL>
SQL> Select p.idd,p.num,'是' From t_test p
2 ,(Select num, Count(1) cc From t_test Group By num) t
3 Where p.num=t.num
4 And cc>1
5 Union All
6 Select p.idd,p.num,'否' From t_test p
7 ,(Select num, Count(1) cc From t_test Group By num) t
8 Where p.num=t.num
9 And cc=1
10 ;IDD NUM '是'
---------- ---------- ----
b 002 是
b 002 是
f 002 是
c 003 是
d 003 是
k 001 否6 行 已选择SQL>
---------- ----------
k 001
b 002
c 003
d 003
b 002
f 0026 行 已选择SQL>
SQL> Select p.idd,p.num,'是' From t_test p
2 ,(Select num, Count(1) cc From t_test Group By num) t
3 Where p.num=t.num
4 And cc>1
5 Union All
6 Select p.idd,p.num,'否' From t_test p
7 ,(Select num, Count(1) cc From t_test Group By num) t
8 Where p.num=t.num
9 And cc=1
10 ;IDD NUM '是'
---------- ---------- ----
b 002 是
b 002 是
f 002 是
c 003 是
d 003 是
k 001 否6 行 已选择SQL>
(
select b,count(1) no from tes group by b
) y
where x.b=y.b;