简体   繁体   中英

How to merge rows in sql

I am trying to understand how to merge two rows (which are the same) into one. They both have data that needs to be in the same row but the raw data currently has split them into two rows. Essentially, I need AML business 1 to be on one row with values for 2019:W26 - 2019:W29. Thank you!

在此处输入图像描述

All answer above ar correct, try this one:

SELECT
        Team,
        MAX(2019-W26) AS 2019-W26,
        MAX(2019-W26) AS 2019-W27,
        MAX(2019-W26) AS 2019-W28,
        MAX(2019-W26) AS 2019-W29
    FROM
        table_name
    GROUP BY
    Team;

If you'd like to have all your information is one row, you can create a view combining both of your two rows into one.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM