title: How to write a select inside case statement
body: <p>I have a stored procedure that contains a case statement inside a select statement.  </p>
  
  <pre><code>select Invoice_ID, 'Unknown' as Invoice_Status, 
  case when Invoice_Printed is null then '' else 'Y' end as Invoice_Printed, 
  case when Invoice_DeliveryDate is null then '' else 'Y' end as Invoice_Delivered, 
  case when Invoice_DeliveryType &lt;&gt; 'USPS' then '' else 'Y' end as Invoice_eDeliver, 
  Invoice_ContactLName+', '+Invoice_ContactFName as ContactName, 
  from dbo.Invoice
  left outer join dbo.fnInvoiceCurrentStatus() on Invoice_ID=CUST_InvoiceID 
  where CUST_StatusID= 7 
  order by Inv_Created  
  </code></pre>
  
  <p>At line <code>case when Invoice_DeliveryType &lt;&gt; 'USPS' then '' else 'Y' end as Invoice_eDeliver</code>   </p>
  
  <p>I need to check for a valid email address (if email is valid, display Y, else display N).  </p>
  
  <p>So the line would read:   </p>
  
  <p><code>if Invoice_DeliveryType &lt;&gt; 'USPS' then '' else ( If ISNULL(Select emailaddr from dbo.Client Where Client_ID = SUBSTRING(Invoice_ID, 1, 6)), 'Y', 'N')</code>   </p>
  
  <p>How can I write out this query?</p>