1. SELECT ORDER
FROM ORDERLIST
WHERE IsCompleted='Y'
2. SELECT ORDER
FROM ORDERLIST
WHERE IsCompleted='N'
然后输出是' NULL'
我想整合这两个逻辑,但我不知道如何使代码工作。请帮帮我!
答案 0 :(得分:2)
试试这个......
您可以使用CASE WHEN
表达式
SELECT
CASE
WHEN IsCompleted='Y'
THEN
[ORDER]
ELSE WHEN IsCompleted='N'
THEN
NULL
END
FROM
ORDERLIST
答案 1 :(得分:0)
'分类:G642.44'如UNION
?:
SELECT ORDER
FROM ORDERLIST
WHERE IsCompleted='Y'
UNION
SELECT NULL
FROM ORDERLIST
WHERE IsCompleted='N'
答案 2 :(得分:0)
试试这个,这应该可以让你在一个表中得到所有结果。
SELECT ORDER
FROM ORDERLIST
WHERE IsCompleted = 'Y' OR IsCompleted = 'N'