Mam tabelę A i B.
W wyniku złączenia powstaje mniej więcej coś takiego:
A.id | A.col | B.name | B.value
---------------- | -------------------
1 | kolumna1 | atrybut1 | 1
1 | kolumna1 | atrybut2 | 10
1 | kolumna1 | atrybut3 | 100
2 | kolumna2 | atrybut1 | 2
2 | kolumna2 | atrybut2 | 20
2 | kolumna2 | atrybut3 | 200
3 | kolumna3 | atrybut1 | 3
3 | kolumna3 | atrybut3 | 300
Każdy atrybut chcę wyświetlić w osobnej kolumnie.
Udało mi się powyższy wynik zamienić na:
A.id | A.col | attr1 | attr2 | attr3
---------------- | -------------------
1 | kolumna1 | 1 | null | null
2 | kolumna2 | 2 | null | null
3 | kolumna3 | 3 | null | null
1 | kolumna1 | null | 10 | null
2 | kolumna2 | null | 20 | null
1 | kolumna1 | null | null | 100
2 | kolumna2 | null | null | 200
3 | kolumna3 | null | null | 300
Jednak nie wiem w jaki sposób usunąć nadmiarowe nulle.
Ostateczny rezultat jaki próbuję osiągnąć:
A.id | A.col | attr1 | attr2 | attr3
---------------- | -------------------
1 | kolumna1 | 1 | 10 | 100
2 | kolumna2 | 2 | 20 | 200
3 | kolumna3 | 3 | null | 300
I właśnie z tym ostatnim jest problem - co powinno zawierać w sobie takie zapytanie?