我想将同一列的值连接到单独的列
假设有名为types和text的列
TYPES TEXT
A This is a
B This is b
C This is c
我希望输出为:
Con
This is c | This is a
This is c | This is b
答案 0 :(得分:0)
我认为与自己联系可以帮助你:
这是伪代码
select t.text || tb.text || tc.text
from t
inner join t tb using(types)
inner join t tc using(types)
因此,要连接A和C列,您可以尝试以下操作:
select t.text || tc.text
from t
full outer join t tc using(types)
where t.types = 'A' and tc.types = 'C'
答案 1 :(得分:0)
select concat(t1.text ,' | ', t2.text ) from tablename t1
inner join tablename t2
on t1.types <> t2.types