You can translate the question and the replies:

How to include a subquery in the CASE clause of a field expression

Hi Denodo Team, Is there any function to add subquery in CASE clause of field expression? For example, case when Type like 'something' then 0 else (select a from table1 where table1.a=table2.a) end
user
09-02-2022 03:18:20 -0500
code

1 Answer

Hi, Going through the question, I understand that you need to include a subquery in the CASE clause of a field expression. If that is the case, then the result of the CASE statement must be a single value, not a result set. This is the behavior of Denodo Platform as well as other databases such as MYSQL. In order to resolve the issue I would rewrite the query using[ joins](https://community.denodo.com/docs/html/browse/8.0/en/vdp/vql/queries_select_statement/from_clause/join_operation) and case statements that return single values. You could refer to the[ CASE Clause](https://community.denodo.com/docs/html/browse/latest/en/vdp/vql/queries_select_statement/case_clause/case_clause) section of the Virtual DataPort VQL Guide for further information about the syntax of a case statement. Hope this helps!
Denodo Team
10-02-2022 01:27:40 -0500
code
You must sign in to add an answer. If you do not have an account, you can register here