我的选择查询:
SELECT
ResultTag, Overallstatus, ProcessOrder
FROM
Evaluation
UNION
SELECT
'2' AS ResultTag,
'Approve' AS Overallstatus,
'6' AS ProcessOrder
预期结果:
---------- ---------- ----------
Result Tag Overallstatus ProcessOrder
---------- ---------- ----------
0 Approved 1
1 Reject 2
. .
. .
2 Approve 6
我需要结合两个选择查询的结果。我尝试使用UNION
但它只导致第一个查询输出。
先谢谢你的帮助..
答案 0 :(得分:0)
如果你有一个重复的行,你应该将Union
更改为union All
,但是如果没有任何重复并且你没有得到第二个查询结果则会出现问题
答案 1 :(得分:0)
使用UNION ALL声明:
SELECT ResultTag,Overallstatus,ProcessOrder
FROM Evaluation
UNION ALL
SELECT '2' AS ResultTag,'Approve' AS Overallstatus,'6' AS ProcessOrder
答案 2 :(得分:0)
结果可能有重复,请使用UNION ALL
SELECT
ResultTag,Overallstatus,ProcessOrder from Evaluation
UNION ALL
SELECT
'2' AS ResultTag,
'Approve' AS Overallstatus,
'6' AS ProcessOrder