Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一张像这样的桌子:
Col1 Col2 Col3 Col4 1 a 1 b 1 c 2 e 2 f 2 g
我需要编写一个查询,它将具有这样的输出
Col1 Col2 Col3 Col4 1 a b c 2 e f g
我正在使用 oracle 10g
如果每列只有一个值,则可以使用聚合函数:
select col1, max(col2) col2, max(col3) col3, max(col4) col4 from yourtable group by col1
请参阅带有演示的 SQL Fiddle
结果是:
| COL1 | COL2 | COL3 | COL4 | ----------------------------- | 1 | b | a | c | | 2 | e | f | g |