当(选择...)中的sql情况
我不是SQL的专家,但我还没有发现类似的问题,也许太明显了... 因此,这是我的问题:
我有几个临时视图,例如“ Contract_ids_canceled”或“ Contract_ids_changed_date”,带有合同ID。我有一个大桌,所有这些合同ID等等。 现在,我想在新列中“标记”它们。我尝试了以下操作:
CASE WHEN contractid in (SELECT DISTINCT contractid FROM contract_ids_canceled) THEN 'contract canceled'
WHEN contractid in (SELECT blabla) THEN 'contract changed'
END as updates
但是我收到以下错误消息
SQL语句中的错误:AnalySisexception:IN/存在谓词子Queries只能在过滤器/加入和几个命令中使用:
如果我使用类似的东西
IN (1,2,3)
,那么我会有些丢失,为什么为什么选择select语句案例不起作用,关于错误消息...如果有人可以在这里帮助我,那就太好了!
Databricks SQL。
I am not an expert on sql, but I have not found a similar issue, maybe it is too obvious...
So here is my question:
I have a couple of temp views like 'contract_ids_canceled' or 'contract_ids_changed_date' with contract ids. And I have a big table with all those contract ids and more.
Now I want to kind of 'tag' them in a new column. I have tried the following:
CASE WHEN contractid in (SELECT DISTINCT contractid FROM contract_ids_canceled) THEN 'contract canceled'
WHEN contractid in (SELECT blabla) THEN 'contract changed'
END as updates
but I get the following error message
Error in SQL statement: AnalysisException: IN/EXISTS predicate sub-queries can only be used in Filter/Join and a few commands:
If I am using something like
IN (1,2,3)
then the IN works, so I am a bit lost why the SELECT statement in the CASE is not working and about the error message... Would be nice if someone could help me out here!
Databricks SQL.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
正如错误指示的那样,databricks不使用或
中的
中的 case> case 语句中的。作为替代方案,请考虑外部连接每个观点以主持合同表:中的
中的As error indicates, Databricks does not support subqueries using
IN
orEXISTS
inCASE
statements. As an alternative, consider outer joining each view to master contract table: