MySQL Forums
Forum List  »  Newbie

Re: Help on SubQuery on same table
Posted by: laptop alias
Date: June 18, 2012 04:47AM

Personally, I'd handle this kind of thing (issues of data display as opposed to data retrieval) at the application level (e.g. with a bit of PHP), but in a case like this (where the number of grades is constant) you can also consider something like this...

SELECT item
     , month
     , COALESCE(MAX(CASE WHEN type = 'Grade1' THEN count END),0) Grade1
    -- ...
  FROM apples_and_oranges 
 GROUP 
    BY item
     , month;

Oh, and read up on normalization.



Edited 1 time(s). Last edit at 06/18/2012 04:52AM by laptop alias.

Options: ReplyQuote


Subject
Written By
Posted
Re: Help on SubQuery on same table
June 18, 2012 04:47AM


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.