Thevagabond
Thevagabond

Reputation: 323

Concat sql result rows on scertain fields

I have the following result set:

ID  |  mark   |  cost   | comment  
 1      yel       45        array
 3      yel       45        tack

Now I want to only have 1 row like:

ID  |  mark   |  cost   | comment  
 1      yel       45        array tack

if mark and cost are the same.

Any ideas on how to do that?

Upvotes: 0

Views: 210

Answers (1)

Romesh
Romesh

Reputation: 2274

select min(id),
       mark,
       cost,
       substr( xmlserialize( xmlagg( xmltext( concat( ' ', comment ) ) ) as varchar( 1024 ) ), 3 )
  from t1
 group by mark,
          cost;

Upvotes: 1

Related Questions