我有一个问题,有人可以帮助我吗?
我有两个SQL查询,一个是在报表计算视图顶部的查询,另一个是在报表CV的基本CV上的查询。现在,我需要比较两个输出是否匹配。
有人可以为此建议SQL查询吗?
这是我要在SAP HANA Studio中获取输出的查询:
Select *
From
(Select X, Y
From Table1
Minus
Select X,Y
From Table2);
还有其他建议吗?
非常感谢
问候 钱德拉巴布
答案 0 :(得分:0)
这是我的选择:
第一
SELECT * FROM
(
SELECT "X", "Y" FROM Table1
EXCEPT
SELECT "X", "Y" FROM Table2
)
UNION
(
SELECT "X", "Y" FROM Table2
EXCEPT
SELECT "X", "Y" FROM Table1
);
第二:
SELECT "X", "Y" FROM
(
SELECT "X", "Y" FROM Table1
UNION ALL
SELECT "X", "Y" FROM Table2
)
GROUP BY
"X", "Y"
HAVING COUNT(1) = 1;
第三:
SELECT
IFNULL(T1."X",T2."X") AS "X",
IFNULL(T1."Y",T2."Y") AS "Y"
FROM
Table1 T1
FULL OUTER JOIN Table2 T2 ON T1."X" = T2."X" AND T1."Y" = T2."Y"
WHERE
T1."X" IS NULL OR T2."X" IS NULL;
答案 1 :(得分:0)