-1

Is it possible to group SQL rows with the same column value into one row?

Simple table to demonstrate what I mean

Ryan
  • 1
  • 2
    Which database? – Sam M Dec 10 '18 at 04:36
  • Possible duplicate of [How Stuff and 'For Xml Path' work in Sql Server](https://stackoverflow.com/questions/31211506/how-stuff-and-for-xml-path-work-in-sql-server) – iminiki Dec 10 '18 at 04:59
  • What [tag:rdbms] are you using? – Mureinik Dec 10 '18 at 06:08
  • Please read http://meta.stackoverflow.com/questions/285551/why-may-i-not-upload-images-of-code-on-so-when-asking-a-question/285557 and the accepted answer –  Dec 10 '18 at 07:03
  • In Postgres you can use `string_agg()` - see [here](https://stackoverflow.com/questions/tagged/string-aggregation+sql) for answers to this question for various DBMS products –  Dec 10 '18 at 07:03

1 Answers1

0

For Postgresql string_agg For Mysql use GROUP_CONCAT Please try i.e mysql

SELECT 
    ID,
    GROUP_CONCAT(CONCAT_WS( ':', title, Number )
SEPARATOR ',' ) AS Title
FROM
    example        
GROUP BY ID
Dipti
  • 565
  • 3
  • 12