MySQL Forums
Forum List  »  Newbie

Re: insert 0 when combing tables?
Posted by: Chad Bourque
Date: September 24, 2010 04:21PM

Good job for the way you posted your question. ;-) Something like this is what you're looking for:

select category,
    sum(case month(date) when 8 then cost else 0 end) August,
    sum(case month(date) when 9 then cost else 0 end) September,
    sum(cost) Total
  from transactions
  group by category;

HTH,
Chad

Options: ReplyQuote


Subject
Written By
Posted
m b
September 24, 2010 03:41PM
Re: insert 0 when combing tables?
September 24, 2010 04:21PM
m b
September 26, 2010 10:11AM
September 26, 2010 12:43PM
m b
September 26, 2010 02:49PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.