title: Division using select statement in mysql
body: <p>I'm trying to divide two select queries but I have a problem in the divisor which throws "Error Code: 1242. Subquery returns more than 1 row"</p>
  
  <p>This is what my statement looks like</p>
  
  <p>The below statement works fine giving me a list of summed values grouped by col2:</p>
  
  <pre><code>(select sum(Tab1.col1) from Tab1 where
   Tab1.col2 in(select Tab1.col2 from Tab1 join Tab2 on Tab2.col2=Tab1.col2 ) 
   and Tab1.col3='general_consumption' group by Tab11.col2);
  </code></pre>
  
  <p>However when I use it the above query like below:</p>
  
  <pre><code>(Select (Tab1.Col4)from Tab1) /(select sum(Tab1.col1) from Tab1 where
   Tab1.col2 in(select Tab1.col2 from Tab1 join Tab2 on Tab2.col2=Tab1.col2 ) 
   and Tab1.col3='general_consumption' group by Tab11.col2);
  </code></pre>
  
  <p>I get this error: </p>
  
  <blockquote>
    <p>Error Code: 1242. Subquery returns more than 1 row</p>
  </blockquote>
  
  <p>Let me know if I can use it any other way.</p>