Hi, my problem is next:
I have existing table like this:
01/01/2010 02/01/2010 03/01/2010
code1 val11 val12 val13
code2 val21 val22 val23
code3 val31 val32 val33
And I need to reorganize it and somehow transform it to new table like this:
DATE VALUE
code1 01/01/2010 val11
code1 02/01/2010 val12
code1 03/01/2010 val13
code2 01/01/2010 val21
code2 02/01/2010 val22
code2 03/01/2010 val23
code3 01/01/2010 val31
code3 02/01/2010 val32
code3 03/01/2010 val33
I have no idea how to begin with this?
Thank you!
SOLUTION:
Actually, I've solved it with union query:
But the problem is that there is a ton of these dates arreanged in columns. Is there a way to automatize it or I need to write SQL code manually for each date?
I have existing table like this:
01/01/2010 02/01/2010 03/01/2010
code1 val11 val12 val13
code2 val21 val22 val23
code3 val31 val32 val33
And I need to reorganize it and somehow transform it to new table like this:
DATE VALUE
code1 01/01/2010 val11
code1 02/01/2010 val12
code1 03/01/2010 val13
code2 01/01/2010 val21
code2 02/01/2010 val22
code2 03/01/2010 val23
code3 01/01/2010 val31
code3 02/01/2010 val32
code3 03/01/2010 val33
I have no idea how to begin with this?
Thank you!
SOLUTION:
Actually, I've solved it with union query:
Code:
SELECT tblOld.Desc, "01/01/2010" AS [Date], tblOld.[01/01/2010] AS [Value] FROM tblOld union all SELECT tblOld.Desc, "02/01/2010" AS [Date], tblOld.[02/01/2010] AS [Value] FROM tblOld UNION ALL SELECT tblOld.Desc, "03/01/2010" AS [Date], tblOld.[03/01/2010] AS [Value] FROM tblOld;
Comment