In a database, it contains a Table
ID Name MTH201401UN MTH201401LC MTH201312UN MTH201312LC MTH201311UN MTH201311LC
1 A 200 300 400 500 600 700
Want a unpivoted table like below:
ID Name Period UN LC
1 A MTH201401 200 300
1 A MTH201312 400 500
1 A MTH201311 600 700
Main thing the period is not fixed but MTH part is fixed how can I do this which can take the periods without mention it particullarly?
This may help you: This assumes that
LC
andUN
are fixedSAMPLE DATA
SOLUTION USING DYNAMIC SQL