Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 680
  • Last Modified:

help with SQL

I have a job table.  3 columns.   ID, type, and notes.    I want to return one record for each set of records per type, where the notes are merged into one note column. How can I do this?
0
HLRosenberger
Asked:
HLRosenberger
  • 2
1 Solution
 
Dan CraciunIT ConsultantCommented:
SELECT type, GROUP_CONCAT(notes SEPARATOR ' ') FROM jobs
GROUP BY type

Open in new window

HTH,
Dan
0
 
HLRosenbergerAuthor Commented:
is GROUP_CONCAT a built in SQL function?  When I try it, I get:

'GROUP_CONCAT' is not a recognized built-in function name.  I'm using MS SQL Server, not MySQL.
0
 
ste5anSenior DeveloperCommented:
E.g.

SELECT  DISTINCT P.Color ,
        STUFF(( SELECT  DISTINCT ', ' + I.NAME
                FROM    AdventureWorks2012.Production.Product I
                WHERE   I.Color = P.Color
                FOR XML PATH('')
             ), 1, 2, '')
FROM    AdventureWorks2012.Production.Product P
WHERE   NOT P.Color IS NULL;

Open in new window

0
 
HLRosenbergerAuthor Commented:
This worked perfect.  Thanks!
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now