Pivoting rows to Columns

UDA
Enthusiast

Pivoting rows to Columns

Hi,

I have a table with data in the following format

Dept Emp
10 12
10 11
10 13
10 15
10 14
20 50
20 51
20 55
20 40
20 44
20 46
20 33

I want to sort the data , pivot these results based on Dept# and get the first four values in 4 different columns as follows
Dept Emp1 Emp2 Emp3 Emp4
10 11 12 13 14
20 33 40 44 46

Please let me know if pivoting can be done in Teradata SQL and how do i acheive the above results.

Thanks,
Sam
1 REPLY
Senior Apprentice

Re: Pivoting rows to Columns

Hi Sam,

http://www.teradata.com/teradataForum/shwmessage.aspx?forumid=10&messageid=1285

Dieter