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 |
|
steveg
Starting Member
2 Posts |
Posted - 2011-12-09 : 12:21:15
|
| Identifier priority accountnumber123456 1 9999999999 123456 1 8888888888123456 5 0000000001123456 47 1111111111678901 1 2222222222678901 2 0101010101012344 1 9998887767987659 1 0890970707876501 1 7645387076Above represents sample data from my table, in total it has 1.2mil records. As you can see the Identifier field can have multiple identical records, each with a Priority number and a unique account number. It's possible for the same Priority number to exist forthe same Identifier.I need create a new table, transforming (my word) the accountnumber values from rows to columns, by Priority in ascending order. In the event there are duplicate Priority value, just take the first accountnumber. So, my new table would look like this:Identifier account1 account2 account3 account4 ....... up to 56 account fields123456 9999999999 8888888888 0000000001 1111111111678901 2222222222 0101010101 012344 9998887767987659 0890970707 876501 7645387076 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
|
|
steveg
Starting Member
2 Posts |
Posted - 2011-12-09 : 12:48:58
|
| I've seen that, but I'm pretty much a newbie and can't get close. Can you provide SPECIFIC T-SQL? Thank you. |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2011-12-09 : 13:02:29
|
| can you post what you tried?------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
|
|
|