views:

330

answers:

2

I am looking for a solution to use pivot on two tables. My problem though, number/name of column & row headers exist as rows in third table. My third table looks like this:

ID      Name
1       Row1
1       Row2
1       Row3
2       Col1
2       Col2
2       Col3

My final solution should look like this:

         Col1   Col2   Col3  Col4 .........    Total
Row1      4       2     4      2                 12

Row2      2    ...................              ...

Row3      7  ....................                ...

....

Total     12      14    6      3                 80

Thanks in advance

A: 

use the new PIVOT operator

Mladen Prajdic
It cannot take the column names from a table, they should be hardcoded
Quassnoi