I'm trying to produce some output which is dependant on a query of data within a column. The closest I've got to is using a case when exists, but this just gives a 1 or literal text not the value of the respective select.
So basically in following simpified example:
field1, field2, field3
where field2 is the result of a number of selects similar to if .. than
This is closest I have
case when exists (
select ec0.field2 from table ec0 where ...
then 'field2' else null end
) as field2,
from table ec ...
group by ...
(so field2 should be the actual result of a select that passed a condition - for simplity just used a single select)
What's a better way to do this or use something similar to above to achieve this?