-3
我有這兩個表:轉換兩個表到單個表
+-------------+--------+ +----+-------+
| employee_id | val_id | | id | value |
+-------------+--------+ +----+-------+
| 123 | 1 | | 1 | A |
+-------------+--------+ +----+-------+
| 123 | 2 | | 2 | B |
+-------------+--------+ +----+-------+
| 123 | 3 | | 3 | C |
+-------------+--------+ +----+-------+
預期結果
+-------------+-------+-------+-------+
| employee_id | val_1 | val_2 | val_3 | ...
+-------------+-------+-------+-------+
| 123 | A | B | C |
你能幫我請
你應該檢查'Join'和'Pivot'。 –
檢出PIVOT命令http://msdn.microsoft.com/en-us/library/ms177410(v=sql.105).aspx –
你想合併物理的兩個表,或者你想查詢的結果如預期? – xQbert