MySQL Forums
Forum List  »  Newbie

Transform or Pivot(?) or Crosstab(?) table in mySQL. One data table.
Posted by: Donncha Butler
Date: April 08, 2006 05:14AM

I have a table in the form

year | season | hits

2004 | Summer | 42
2004 | Autumn | 43
2005 | Spring | 51
2005 | Summer | 52
2005 | Autumn | 53
2006 | Spring | 61

I want to generate a transform or pivot or crosstab - I'm not sure what the correct term is - to return the data in form

year | Spring | Summer | Autumn
2004 | ------ | ----42 | ----43
2005 | ----51 | ----52 | ----53
2006 | ----61 | ------ | ------

Could anyone suggest a mysql query to generate the required output?

Sorry about bad formatting of query but this board doesn't seem to accept bbcode.

Many thanks.

Options: ReplyQuote


Subject
Written By
Posted
Transform or Pivot(?) or Crosstab(?) table in mySQL. One data table.
April 08, 2006 05:14AM


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.