title: How do I execute different SELECT statements based on a CASE
body: <p>I am facing a problem in executing queries with CASE statement.
  Based on my condition,(for eg. length), I want to execute different SQL statement.</p>
  
  <p>Problematic sample query is as follows:</p>
  
  <pre><code>select case 
      when char_length('19480821') = 8
          then select count(1) from Patient
      when char_length('19480821')=10
          then select count(1) from Doctor 
  end
  </code></pre>
  
  <p>Exception:</p>
  
  <blockquote>
    <p>[Error] Script lines: 1-5 --------------------------<br>
    Incorrect syntax near the keyword 'select'.<br>
    Msg: 156, Level: 15, State: 2<br>
    Server: sunsrv4z7, Line: 2  </p>
  </blockquote>
  
  <p>I am not able to correct the syntax. I am getting the string for char_length as input from the user.
  How can I fire queries based on certain condition?
  Is CASE the right choice ? Or do I have to use any other thing.</p>