Unanswered: Using select statement inside a CASE WHEN expression
Need help in writing query for the below scenario:
I have a table T1 which has columns say TM_ID and ALT_ID. I need to select a set of TM_IDs. If this ALT_ID has a value zero the I need to select all TM_IDs from another table T2 else the TM_ID from T1
So here is the question.
I need to select TM_IDs from table T1 for a particular ALT_ID. IF TM_ID is zero then I need to select all teams from another table T2. Else TM_ID from table T1. I tried using select inside a CASE like below :
SELCT TM_ID from T1
WHEN 0 THEN SELECT TM_ID from T2
from T1 where ALT_ID='222'