My requirement is to get a number from a complex query and check if the num = desiredNum.
If it is equal to desiredNum, then I must perform another set of select statements,
Is there any way I can achieve this in a query rather than writing a function?
Eg:
select case when val =2  
then select val1 from table1  
else 'false'  
from (select val from table)  
Is this possible ??
select case when val=2 then val1 else val end as thevalue
from table1
I assume you meant that val and val1 are both from the same table, but when val=2, to use val1 instead. If you actually had two tables, and they both have only one record each, then
select
    case when val=2
    then (select val1 from table1)
    else 'false'
    end
from table
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With