![]() | |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
I have a table with three fields (giver, taker, amount) I have another table of people with two fields (id, name) The fields "giver" and "taker" are match the values of "id" I'd like to make a table (I've heard it called a distance matrix, but this one's a little different because it's no symmetrical along the major axis) using SQL (I _could_ do it with an external language, but would prefer straight SQL). So let's say in the id/name table I've got: 1 | Jim 2 | Bob 3 | James And in the giver/taker/amount table I've got (note that there's multiple giver-taker entries) giver | taker | amount 1 | 2 | 20 1 | 3 | 10 1 | 2 | 8 2 | 1 | 18 2 | 1 | 5 2 | 3 | 70 3 | 1 | 64 I would like an SQL query that produces the following (the columns being dynamic -- is that even possible?): Giver | toJim | toBob | toJames Jim | 0 | 28 | 10 Bob | 23 | 0 | 70 James | 64 | 0 | 0 Is this possible with SQL |
#3
| |||
| |||
|
|
I have a table with three fields (giver, taker, amount) I have another table of people with two fields (id, name) The fields "giver" and "taker" are match the values of "id" I'd like to make a table (I've heard it called a distance matrix, but this one's a little different because it's no symmetrical along the major axis) using SQL (I _could_ do it with an external language, but would prefer straight SQL). |
#4
| |||
| |||
|
![]() |
| Thread Tools | |
| Display Modes | |
| |