Skip to content Skip to sidebar Skip to footer

How To Write A Select Inside Case Statement

I have a stored procedure that contains a case statement inside a select statement. select Invoice_ID, 'Unknown' as Invoice_Status, case when Invoice_Printed is null then '' els

Solution 1:

You can do this with a case. I think the following is the logic you want:

(case when Invoice_DeliveryType <> 'USPS' then ''
      when exists (Select 1
                   from dbo.Client c
                   Where c.Client_ID = SUBSTRING(i.Invoice_ID, 1, 6) and
                         c.emailaddr is not null
                  )
      then 'Y'
      else 'N'
 end)

Post a Comment for "How To Write A Select Inside Case Statement"