@ChineduLB
Impala doesn't directly support nested select statements within the WHEN clause of a CASE statement. However, you can achieve similar logic
Subqueries for conditions: You can use subqueries within the WHEN clause to evaluate conditions based on data retrieved from other tables.
SELECT
case
when (select count(*) from table1) > 0 then (select * from table1)
when (select count(*) from table2) > 0 and (select count(*) from table3) > 0 then (select * from table3)
else null
end as result_table;
This query checks if table1 has any rows. If yes, it selects all columns from table1. Otherwise, it checks if both table2 and table3 have rows. If both have data, it selects all columns from table3. If none of the conditions are met, it returns null.