简体   繁体   中英

sql combining rows of the same primary key

In here you can see the nested or statement which allows me to combine the answers.text and answers.integer to the same table in some order

But what I would like to do is have the integers and text on the same row if they have the same submission id. How would I do that?

EDIT: The concat was supposed to combine the two on the same line, or so I thought. But it had just took out the nulls from the columns so that there were only two -> submissions and building_idquant. When before there was submission_id, building_id, and integer.

its tough to get your expectation from image but i thought after seeing your image you need below somethin

select submission_id,building_idquant ,
    concat(CONVERT(varchar(50), submission_id),building_idquant ) as id_quant from
    (
    select distinct submission_id,building_idquant from tablename 
    ) t

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