SQL Query to concatenate column values from multiple rows in Oracle -
would possible construct sql concatenate column values multiple rows?
the following example:
table a
pid b c
table b
pid seq desc 1 have 2 nice 3 day. b 1 nice work. c 1 yes c 2 can c 3 c 4 work!
output of sql should -
pid desc have nice day. b nice work. c yes can work!
so desc column out put table concatenation of seq values table b?
any sql?
there few ways depending on version have - see oracle documentation on string aggregation techniques. common 1 use listagg:
select pid, listagg(desc, ' ') within group (order seq) desc b group pid; then join a pick out pids want.
note: out of box, listagg works correctly varchar2 columns.
Comments
Post a Comment