I have a table DEFINITION with this content:
def_id game_id generaldef_id definition
========================================
1 1 1
firstname
2 1 2 lastname
3 1 3 age
4 1 4 status
5 1 5 position
6 2 6 firstname
7 2 7 lastname
8 2 8 nickname
etc...
Note: There are many possible values to the "definition" row. So the
solutions needs to be DYNAMIC!
Note 2: Don't worry too much about different game_id's, they are for
different kind of games...
Then I have another table PLAYERDEF with the following values:
playedef_id user_id generaldef_id value
======================================
1 1 1 allan
2 1 2
shearer
3 1 3 44
4 1 4 retired
5 1 5 forward
6 2 1 george
7 2 2
mitropoulos
etc...
Then I have a USER TABLE somewhere, but I leave it out now...
How can I merge these tables into this kind of RESULT_SET:
game_id user_id firstname lastname age
status position ....
================================================== ===============
1 1 allan shearer
44 retired forward
1 2 george mitropoulos 26
active goalie
etc...
So I need some kind of crosstabbing, or pivoting or rotating....
Any help appreciated.
I'm on SQL Server 2005.
-pom-