我有一张雪花桌如下:
create table field_names_to_retrieve("QualifiedApiName" varchar(80));
INSERT INTO field_names_to_retrieve VALUES ('reason');
INSERT INTO field_names_to_retrieve VALUES ('reason__c');
INSERT INTO field_names_to_retrieve VALUES ('name__c');
INSERT INTO field_names_to_retrieve VALUES ('email__c');
如果我运行以下查询,它将工作:
SELECT
"QualifiedApiName",
CASE WHEN UPPER(REGEXP_REPLACE("QualifiedApiName", '__c$', '')) NOT IN
(SELECT "QualifiedApiName" FROM "field_names_to_retrieve")
THEN REGEXP_REPLACE("QualifiedApiName", '__c$', '')
ELSE "QualifiedApiName"
END
FROM
"field_names_to_retrieve";
但是,以下查询不起作用。请注意,在子查询的upper中有:
SELECT
"QualifiedApiName",
CASE WHEN UPPER(REGEXP_REPLACE("QualifiedApiName", '__c$', '')) NOT IN
(SELECT UPPER("QualifiedApiName") FROM "field_names_to_retrieve")
THEN REGEXP_REPLACE("QualifiedApiName", '__c$', '')
ELSE "QualifiedApiName"
END
FROM
"field_names_to_retrieve";
你知道为什么带upper的子查询失败了吗?
1条答案
按热度按时间44u64gxh1#
很明显,这个表达是一个问题
NOT IN
. 我不鼓励使用NOT IN
因为NULL
值不是直观地处理的。它对你有用吗
NOT EXISTS
?