我有一個看起來是這個樣子的3和3個重複行的表...MS SQL集團行
Column1 | Column2
CustomerID | 22
CustomerName | 」ABC」
Responsible | 」Allan」
CustomerID | 23
CustomerName | 」DEF」
Responsible | 」Jessica」
CustomerID | 24
CustomerName | 」GHI」
Responsible | 」Paul」
下面的腳本可以用來創建表並填充它樣本數據...
CREATE TABLE Responsible
([ RowType ] VARCHAR(12),
[ Value ] VARCHAR(9))
;
INSERT INTO Responsible
([RowType],
[ Value ])
VALUES
('CustomerID',
'22'),
('CustomerName',
'ABC'),
('Responsible',
'Allan'),
('CustomerID',
'23'),
('CustomerName',
'DEF'),
('Responsible',
'Jessica'),
('CustomerID',
'24'),
('CustomerName',
'GHI'),
('Responsible',
'Paul');
而且我想獲得它像一個表,看起來像這樣:
CustomerID | CustomerName | Responsible
22 | ABC | Allan
23 | DEF | Jessica
24 | GHI | Paul
什麼是最好的前進方向?
什麼數據庫引擎?你沒有任何領域可以在你的桌子上分組嗎? – Blag
您正在使用哪些DBMS? Postgres的?甲骨文? –
你不能這樣做。 SQL表格表示*無序*行。如果沒有指定順序的列,則無法可靠地連接行。 –