我有一张这样的桌子:
+-------+-------+-------+-------+
| ID | City | Param | Value |
+-------+-------+-------+-------+
| id1 | city1 | a | value |
| id2 | city1 | b | value |
| id3 | city1 | c | value |
| id4 | city2 | a | value |
| id5 | city2 | b | value |
| id6 | city2 | c | value |
| ... | ... | ... | ... |
| idN | cityN | a | value |
| idN+1 | cityN | b | value |
| idN+2 | cityN | c | value |
+-------+-------+-------+-------+
如您所见,它为每个城市都有一个子表,例如:
+-------+-------+
| Param | Value |
+-------+-------+
| a | value |
| b | value |
| c | value |
+-------+-------+
所以我想加入所有子表并得到一个这样的表:
+-------+-------+-------+-----+-------+
| Param | city1 | city2 | ... | cityN |
+-------+-------+-------+-----+-------+
| a | value | value | ... | value |
| b | value | value | ... | value |
| c | value | value | ... | value |
+-------+-------+-------+-----+-------+
任何想法我怎么能得到它?
先感谢您!
注1:城市数量不定。
注意 2:解决方案可以是 PL/SQL 函数。