Sql 我如何连接;“保留地形图”;在一个单一的结果中

Sql 我如何连接;“保留地形图”;在一个单一的结果中,sql,postgresql,Sql,Postgresql,这是我查询的实际输出(使用PostgreSQL数据库) 我想把最后一列分组,得到这样的结果,分隔符是一个空格 请随时问我任何其他问题 提前感谢看起来您想连接最后一列。为此,我更喜欢数组: select includ, Article_Ref, Name, Quantite, array_agg(Repere) from MyTable group by includ, Article_Ref, Name, Quantite; 如果您喜欢字符串: select includ,

这是我查询的实际输出(使用PostgreSQL数据库)

我想把最后一列分组,得到这样的结果,分隔符是一个空格

请随时问我任何其他问题


提前感谢

看起来您想连接最后一列。为此,我更喜欢数组:

select includ, Article_Ref, Name, Quantite,
       array_agg(Repere)
from MyTable 
group by includ, Article_Ref, Name, Quantite;
如果您喜欢字符串:

select includ, Article_Ref, Name, Quantite,
       string_agg(Repere, ' ')
from MyTable 
group by includ, Article_Ref, Name, Quantite;

非常感谢@Gordon。我用了一根绳子,效果很好。
select includ, Article_Ref, Name, Quantite,
       string_agg(Repere, ' ')
from MyTable 
group by includ, Article_Ref, Name, Quantite;