Postgres:如何将列组合到同一行值

时间:2018-02-26 23:05:32

标签: sql postgresql

如何组合多个可以放入同一行的列而不是多次显示相同的行?

goto

分为:

flight               | Manager   | Lead  | Worker
---------------------|-----------|-------|--------
Arizona_BGS_Flight_2 | John      |       |
Arizona_BGS_Flight_2 |           | Will  |
Arizona_BGS_Flight_2 |           |       | James
Utah_UTS_Flight_5    | John      |       |

1 个答案:

答案 0 :(得分:0)

您可以使用聚合:

select flight, max(manager) as manager, max(lead) as lead, max(worker) as worker
from t
group by flight;