我正在尝试生成如下所示的报告。我们正在根据某些条件比较COLUMN_A和COLUMN_B。
COLUMN_A COLUMN_B STATUS
100 OK
250 350 NOT OK
300 NULL NULL COLUMN_A
NULL 400 NULL COLUMN_B
这让我很困惑。这甚至可能得到吗?
答案 0 :(得分:3)
这是你想要的吗?
select column_a,
(case when column_a = column_b or column_b is null then null else column_b end) as column_b,
(case when column_a = column_b then 'OK'
when column_b is null then 'NULL ' || column_a
when column_a is null then 'NULL' || column_b
else 'NOT OK'
end) as status
from . . .