title: Return multiple fields using case in select statement of sql server
body: <p>I have a table tb3 wherein id,name,sal are to be displayed using a <code>SELECT</code> statement and city,descrip fields need to be displayed in the same <code>SELECT</code> statement only when the flag is 'Y'. How do I do this using <code>CASE</code> statements?</p>
  
  <pre><code>      id    name    sal city    descrip flag
         7    john    80000.00    Canada  prog    y
         6    jone    90000.00    NY  test    y
         3    san 70000.00    NY        lead  y
         2    sam 70000.00    Cali    sub n
         1    sally   60000.00    Canada  archi   n
         4    carl    70000.00    SA  plain   n
  </code></pre>
  
  <p>I need to do something like this.. I know it's wrong , but for a sample please have a look..</p>
  
  <pre><code>       declare @test varchar(1)
         select @test=flag from tb3
         select id,name,case @test
         when 'Y' then select city,descrip from tb3
         when 'n' then 'inactive'
         end as status from tb3
  </code></pre>