-5

I have table

 Table  column name description name
Tab1       Col1            Col1 -Desc1
Tab1       Col1            Col1-Desc2
Tab1       col2            Col2 Desc
Tab2       col3            Col3 Desc
Tab2       col4            COL4 Desc

I want to build aggregation result meaning that each instance of table will be only once in the new table and it will do aggregation to the column name and to the description.

Table   column name     description name
Tab1    Col1,co1,col2          Col1 –Desc1, Col1-Desc2, Col2 Desc
Tab2    col3,col4                   Col3 Desc,Col4 Desc

Is it possible to do it in SQL ?

  • Please specify the RDBMS that you are targeting by adding the appropriate tag (Oracle, SQL Server, MySQL, etc.). There may be answers that take advantage of language or product features that are not universally supported. Also, by tagging it with a specific RDBMS, your question may receive attention from people better suited to answer it. – Taryn Jun 12 '13 at 13:48
  • I am nore sure on the SQL version i think it is SQLISO92 – user2444677 Jun 12 '13 at 14:02
  • 4
    SQLISO92 is the ANSI standard, not the database engine – gbn Jun 12 '13 at 14:04
  • 1
    I am not expert in this so I am not sure but it is not MYSQL – user2444677 Jun 12 '13 at 14:06
  • @user2444677 It is difficult to answer without knowing what database you are using. The syntax will be different depending on the engine. – Taryn Jun 12 '13 at 14:14
  • 1
    At the very least, what program are you opening to access your SQL database? – Jim Dagg Jun 12 '13 at 14:15

1 Answers1

5

MySQL:

SELECT
   `Table`,
   GROUP_CONCAT(`column name`),
   GROUP_CONCAT(`description name`)
FROM
   `MyTable`
GROUP BY
   `Table`
gbn
  • 422,506
  • 82
  • 585
  • 676