Click here to Skip to main content
15,886,689 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
iyear	nu_jan	nu_feb	nu_mar	nu_apr	nu_may	nu_jun	nu_jul	nu_aug	nu_sep	nu_oct	nu_nov	nu_dec
2016	NULL	NULL	NULL	0.2	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL
2016	NULL	NULL	NULL	NULL	0.34	NULL	NULL	NULL	NULL	NULL	NULL	NULL
2016	NULL	NULL	NULL	NULL	NULL	0.34	NULL	NULL	NULL	NULL	NULL	NULL
2016	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	2.76	NULL	NULL	NULL
2016	NULL	NULL	NULL	NULL	NULL	NULL	NULL	2.04	NULL	NULL	NULL	NULL
2016	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	2.1	NULL	NULL
2016	NULL	NULL	NULL	NULL	NULL	NULL	1.62	NULL	NULL	NULL	NULL	NULL
2016	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	2.1
2016	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	2.14	NULL




i want result like this

iyear	nu_jan	nu_feb	nu_mar	nu_apr	nu_may	nu_jun	nu_jul	nu_aug	nu_sep	nu_oct	nu_nov	nu_dec
2016	NULL	NULL	NULL	0.2	.34	.34	1.62	2.04	2.76	2.1	2.14 	2.1


What I have tried:

i have tried to do
PIVOT
. but its not work
Posted
Updated 4-Apr-17 23:52pm
Comments
Jörgen Andersson 5-Apr-17 5:28am    
Pivot should work, show us your code.

1 solution

Just GROUP by year and show the MAX:
SELECT iYear, MAX(nu_jan), MAX(nu_Feb), ...
FROM MyTable
GROUP BY iYear
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900