[prev in list] [next in list] [prev in thread] [next in thread]
List: mysql
Subject: Re: Transpose
From: Baron Schwartz <baron () xaprb ! com>
Date: 2007-04-29 21:16:00
Message-ID: 46350B10.9000809 () xaprb ! com
[Download RAW message or body]
Hi,
Some Body wrote:
> Hi all,
> I have a situation where the data in a table has to
> be transposed.
> I have a table having columns
> id, a_id, a1, a2, a3, a4, ..., an
>
> In the query I need a result similar to
> a_id a_id a_id
> 2001 2002 2003
> a1 1 2 1
> a2 1 5 6
> a3 2 7 2
> a4 3 9 5
> ... .. .. ..
> an n 1 1
>
> How does a SQL statement of stored proc/function look
> like to achieve this?
Giuseppe Maxia wrote a great article on this some time ago. The
technique is called cross-tabulation or pivot tables. Here is a link:
http://www.onlamp.com/pub/a/onlamp/2003/12/04/crosstabs.html
Baron
--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: http://lists.mysql.com/mysql?unsub=mysql-marcsub@progressive-comp.com
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic