I have a sceanrio where i need to retreive values from different sub queries based on a condition in a main select statement. i was trying to use Case, but the problem is that Case does not support multiple columns. Is there any work around to this, or is there any other way to acheive this.
My scenario in a simplified query
select col1,col2, case when col3='E01089001' then (select 1,3 from dual) else (select 2,4 from dual) end from Table1 where col1='A0529';
Here’s another way of writing it which may address concerns about accessing the second table more times than necessary.
Your example uses an obviously simplified subquery, so this version looks kind of silly as-is; there’s no reason to join with DUAL at all. But in your real query you presumably have a subquery like
SELECT a, b FROM otherTable WHERE someCondition. So you would want to use the actual column names instead of numeric literals and the actual table name instead of dual, and move the subquery conditions into the final WHERE clause.