我有两张这样的桌子。
---------------------------------------------------
| AltID | Alan 1| Alan 2 | Alan 3 | UserId |
---------------------------------------------------
| 1 | Opel | null | Engine | 5121 |
| 2 | Home | Garden | null | 5653 |
| 3 | null | null | null | 2133 |
---------------------------------------------------
-------------------------------------
| UserId | Kolon | NewValue |
-------------------------------------
| 2133 | Alan 1 | null |
| 2133 | Alan 2 | null |
| 2133 | Alan 3 | null |
| 5121 | Alan 1 | Brand |
| 5121 | Alan 2 | Model |
| 5121 | Alan 3 | Part |
| 5653 | Alan 1 | Place |
| 5653 | Alan 2 | Point |
| 5653 | Alan 3 | Take |
-------------------------------------
我试图得到这样的结果
-----------------------------------------------------
| UserId | Kolon | NewValue | AltID | Deger |
-----------------------------------------------------
| 2133 | Alan 1 | null | 3 | null |
| 2133 | Alan 2 | null | 3 | null |
| 2133 | Alan 3 | null | 3 | null |
| 5121 | Alan 1 | Brand | 1 | Opel |
| 5121 | Alan 2 | Model | 1 | null |
| 5121 | Alan 3 | Part | 1 | Engine|
| 5653 | Alan 1 | Place | 2 | Home |
| 5653 | Alan 2 | Point | 2 | Garden|
| 5653 | Alan 3 | Take | 2 | null |
-----------------------------------------------------
我只是尝试做 unpivot 但无法将其他表加入到下一个表中。请帮助我吗?