title: a subquery within a subquery - is it possible?
body: <p>I have this sql below that i use to compare values of z. I put z in a subquery and then compare it. </p>
  
  <p>My qn is in in my else statement below, i want to put in another formula to calculate something else of which the info is only available in another table called var1(for example, n). i would like to put in sum(n)/count(n) to end as cv in my else statement. and then make a case statement if the cv > 10 then too large, if &lt; 10 too little. </p>
  
  <p>am i supposed to do another subquery in this subquery? any advise pls. thanks!</p>
  
  <pre><code>select 
  z, 
  CASE 
  when z &gt; 1 then 'Pls increase your inputs' 
  when z &lt; -1 then 'Pls decrease your inputs'
  else 'No comment' END as Input
  
  from 
  
  (select
      case
      when S &lt; 0 then (S/En-Eg))
      else (S/En+Eg)) 
      end as z
  from var2);
  </code></pre>