如何使用CASE语句获取空结果集?

时间:2019-05-30 06:00:27

标签: mysql vertica

我无法在CASE语句中得到空结果。以下查询返回NULL作为结果:

SELECT CASE WHEN ('test' IS NULL) THEN (SELECT 'null_result') ELSE (SELECT 'empty_result' WHERE 1<>1) END;

我想获得空结果(无任何行)。

1 个答案:

答案 0 :(得分:1)

您可以在外部2019-05-27 10:49:18,418 ERROR org.apache.flink.runtime.executiongraph.ExecutionGraph - Job (3064130e1dccead0b037f193d3699c3b) switched from state FAILING to FAILED. java.lang.IllegalArgumentException: json can not be null or empty 子句中过滤掉NULL个值。

WHERE

SELECT CASE WHEN ('test' IS NULL) THEN (SELECT 'null_result') ELSE (SELECT 'empty_result' WHERE 1<>1) END
WHERE CASE WHEN ('test' IS NULL) THEN (SELECT 'null_result') ELSE (SELECT 'empty_result' WHERE 1<>1) END IS NOT NULL;