sql合并相同主键的行

时间:2018-08-09 02:46:09

标签: sql postgresql

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?

编辑:concat应该在同一行上将两者结合在一起,所以我想。但是它只是从列中删除了空值,因此只有两个->提交和building_idquant。之前的时间是Submitting_id,building_id和整数。

1 个答案:

答案 0 :(得分:1)

很难从图像中获得期望,但我想在看到您的图像之后,您需要一点东西

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