Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
vgarzon
Starting Member
11 Posts |
Posted - 2009-10-29 : 11:25:58
|
| Hi all,I'm having issues trng to pivot a table that has the following structure:Employee ID, Date, Field, New Value, Old ValueSupposing that in the "Field" field can have 20 different values, and that every time a field is updated, we record only the updated field in the table.I have to show the data with the following structure:Employee ID, Field 1, Field 2, ...., Field 20Showing only the latest version of the Employee's information.Was I clear enough? jeje.Simplifying things, I have:ID DATE FIELD OLD NEW1 2009-01-01 00:00:00.000 A NULL new11 2009-01-01 00:00:00.000 B NULL new21 2009-01-01 00:00:00.000 C NULL new31 2009-01-01 00:00:00.000 D NULL new42 2009-01-01 00:00:00.000 A NULL bla12 2009-01-01 00:00:00.000 B NULL bla22 2009-01-01 00:00:00.000 C NULL bla32 2009-01-01 00:00:00.000 D NULL bla43 2009-03-01 00:00:00.000 A NULL asd13 2009-03-01 00:00:00.000 B NULL asd23 2009-03-01 00:00:00.000 C NULL asd33 2009-03-01 00:00:00.000 D NULL asd41 2009-05-05 00:20:00.000 C new3 OPAAnd I have to show: A B C D1 new1 new2 OPA new42 bla1 bla2 bla3 bla43 asd1 asd2 asd3 asd4Any ideas of how to do this?Thanks in advance,Victor |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
|
|
|
|
|
|
|