Sql查询除ID以外相同的数据
id NAME AGE
1 n1 1
2 n1 1
3 n2 2
4 n2 2
5 n22 2
6 n2 3
7 n111 1
8 n222 2
9 n333 3
查询结果
ID NAME AGE
1 n1 1
2 n1 1
3 n2 2
4 n2 2
----
WITH T1 AS (SELECT NAME,AGE FROM FABU GROUP BY NAME,AGE HAVING COUNT(*) >= 2)
SELECT ID,NAME,AGE FROM FABU WHERE NAME IN (SELECT NAME FROM T1) AND AGE IN (SELECT AGE FROM T1)