SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2012 Forums
 Transact-SQL (2012)
 Need urgent help on SQL Pivot query
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Tarakeswara_Allu
Starting Member

India
2 Posts

Posted - 03/06/2014 :  23:56:22  Show Profile  Reply with Quote
This is how data is in the table.

Column0 Column1 Column2 Column3 Column4 Column 5
2013 NULL NULL NULL NULL NULL
JED Jan Feb Mar Apr May
WT 24 9 11 10 9
L/B 1058 1859 1088 986 1265
AHL 1212 993 1434 1207 1170
DPR 96 61 74 67 77
Lost 333 333 382 331 353
RR 73 66 73 73 70

and it needs to be reorganized as below.

Year Month Station WT LB AHL DPR LOST RR
2013 Jan JED 24 1058 1212 96 333 73
2013 Feb JED 9 1859 993 61 333 66




Tarakeswara Rao Allu

khtan
In (Som, Ni, Yak)

Singapore
17655 Posts

Posted - 03/07/2014 :  00:18:37  Show Profile  Reply with Quote
refer to http://technet.microsoft.com/en-us/library/ms177410%28v=sql.105%29.aspx


KH
Time is always against us

Go to Top of Page

Tarakeswara_Allu
Starting Member

India
2 Posts

Posted - 03/07/2014 :  00:36:11  Show Profile  Reply with Quote
quote:
Originally posted by khtan

refer to http://technet.microsoft.com/en-us/library/ms177410%28v=sql.105%29.aspx


KH
Time is always against us



but here I don't have to perform any aggregate function

Tarakeswara Rao Allu
Go to Top of Page

khtan
In (Som, Ni, Yak)

Singapore
17655 Posts

Posted - 03/07/2014 :  00:37:42  Show Profile  Reply with Quote
you can use MAX()


KH
Time is always against us

Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.03 seconds. Powered By: Snitz Forums 2000