simak29 has asked for the wisdom of the Perl Monks concerning the following question:
Hello, Newbie here. Is there a way that I can transpose DB rows into columns? I am thinking, that I can read the rows into a hashmap and then do some processing there, but am just not sure how to go about this.
For example: If I have the below table:
id name dept date_joined email date_sent 1 P1 Test 12/10/14 Y 12/11/14 10:53:45 1 P1 Test2 1/1/14 Y 1/05/14 05:25:34 2 P2 Test 3/1/14 N Null 2 P2 Test 8/1/14 Y 8/05/14 11:28:28 3 P2 Test3 10/1/14 N Null
Desired Output is: id name Test Test2 Test3 Y_email N_E +mail 1 P1 12/10/14,8/1/14 1/1/14,3/1/14 10/1/14 12/11/14 10:53:45 +,1/05/14 05:25:35,8/05/14 11:28:28 Null 2 P2 1/1/14,3/1/14 null 10/1/14 Null, Null Basically, trying to transpose and flatten it to get one row per recor +d. Any ideas how I can do this?
Can anyone suggest how I can go about this in the simplest way possible? The data I am dealing with is huge.
Thanks in advance
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Transposing rows to columns
by NetWallah (Canon) on Dec 18, 2014 at 07:27 UTC | |
by simak29 (Novice) on Dec 18, 2014 at 19:57 UTC | |
|
Re: Transposing rows to columns ( pivot table)
by Anonymous Monk on Dec 18, 2014 at 09:06 UTC | |
by simak29 (Novice) on Dec 18, 2014 at 20:04 UTC | |
|
Re: Transposing rows to columns
by poj (Abbot) on Dec 18, 2014 at 09:00 UTC | |
by simak29 (Novice) on Dec 18, 2014 at 19:59 UTC | |
by Laurent_R (Canon) on Dec 18, 2014 at 23:11 UTC | |
|
Re: Transposing rows to columns
by Anonymous Monk on Dec 18, 2014 at 07:54 UTC | |
by simak29 (Novice) on Dec 18, 2014 at 19:58 UTC |