我有一个数据集如下:
SELECT ' 1234 ' ID,NULL TAG,' AB' CODE FROM DUAL
UNION ALL
SELECT '453' ID,'GEN' TAG,'AB' CODE FROM DUAL
UNION ALL
SELECT '1234' ID,NULL TAG,' AB' CODE FROM DUAL)
我正在尝试使用以下查询获取重复项。输出应该是第 1 行和第 3 行,但我只得到一行作为 1 或 3 的修剪输出。
SELECT TRIM(ID),TRIM(TAG),TRIM(CODE) FROM
(SELECT ' 1234 ' ID,NULL TAG,' AB' CODE FROM DUAL
UNION ALL
SELECT '453' ID,'GEN' TAG,'AB' CODE FROM DUAL
UNION ALL
SELECT '1234' ID,NULL TAG,' AB' CODE FROM DUAL)
WHERE (TRIM(ID),TRIM(TAG),TRIM(CODE)) IN
(
SELECT TRIM(ID),TRIM(TAG),TRIM(CODE) FROM
(SELECT ' 1234 ' ID,NULL TAG,' AB' CODE FROM DUAL
UNION ALL
SELECT '453' ID,'GEN' TAG,'AB' CODE FROM DUAL
UNION ALL
SELECT '1234' ID,NULL TAG,' AB' CODE FROM DUAL)
GROUP BY TRIM(ID),TRIM(TAG),TRIM(CODE)
HAVING COUNT(*) >1
)