title: sum of 1 column 2 results diff where per result! so simple yet not working
body: <p>ok this is very simple yet have been searching for 3 hours and still cant get it to work!</p>
  
  <p>the scenario is i have a db with individual costs of 2 business' and i want to sum the cost of each business and present on screen. now i know this is simple enough and easily done with two SELECTS. but i want to do this in one query! </p>
  
  <p>DB</p>
  
  <pre><code>|cost|business|
  |100 |   1    |
  |200 |   2    |
  |200 |   1    |
  |300 |   2    |
  </code></pre>
  
  <p>so from the table above we know that b1 = 300 and b2 = 500! but none of my queries work!</p>
  
  <p>i have tried UNION and CASE but am unfamiliar with them.
  my queries:</p>
  
  <p>first try: </p>
  
  <pre><code>$buscost = mysql_query("SELECT FORMAT(sum(`cost`),2) as `b1` FROM `outgoing` WHERE `business`=1 
  UNION 
  SELECT FORMAT(sum(`cost`),2) as `b2` FROM `outgoing` WHERE `business`=2")
  or die(mysql_error());
      $buscost = mysql_fetch_array($busowe);
  </code></pre>
  
  <p>second try:  </p>
  
  <pre><code>$buscost = mysql_query("SELECT 
  CASE WHEN `business` = 1 THEN FORMAT(sum(`cost`),2) END AS `b1` ,
  CASE WHEN `business` = 2 THEN FORMAT(sum(`cost`),2) END AS `b2`  
  FROM `outgoing` WHERE `active`='yes' ");
  $buscost = mysql_fetch_array($buscost);
  </code></pre>
  
  <p>*cost is set as float(11,2). </p>
  
  <p>im sure im close i just dont know enough to figure it out, have found similar questions on here but none of the answers helped!</p>
  
  <p>oh and if i <code>print_r</code>, the first only fetches the sum of b1, b2 doesnt exist! and
  the second array all i get is the result set of the first case and case 2 "b2" is empty,but exists!! i have checked the tables and there is test data in there for both business'. </p>
  
  <p>please help any advice or a solution is greatly appreciated.</p>
  
  <p>edit:forgot to mention all results will also need to be filtered with where <code>active</code>='yes'</p>