我有一个雪花表如下:
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 的子查询失败的任何想法?