MySQL Forums
Forum List  »  Newbie

Re: Transform or Pivot(?) or Crosstab(?) table in mySQL. One data table.
Posted by: Donncha Butler
Date: April 08, 2006 02:57PM

Bingo, Bob!

In my case the records should be unique so I've modified it using MAX rather than SUM as follows:

SELECT year,
max(if(season='Spring', hits, 0)) AS Spring,
max(if(season='Summer', hits, 0)) AS Summer,
max(if(season='Autumn', hits, 0)) AS Autumn
FROM example
GROUP BY year;

Thank you for your prompt reply.

Options: ReplyQuote


Subject
Written By
Posted
Re: Transform or Pivot(?) or Crosstab(?) table in mySQL. One data table.
April 08, 2006 02:57PM


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.