?
Solved

help with SQL

Posted on 2014-04-23
4
Medium Priority
?
598 Views
Last Modified: 2014-04-23
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
Comment
Question by:HLRosenberger
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 35

Expert Comment

by:Dan Craciun
ID: 40017424
SELECT type, GROUP_CONCAT(notes SEPARATOR ' ') FROM jobs
GROUP BY type

Open in new window

HTH,
Dan
0
 
LVL 1

Author Comment

by:HLRosenberger
ID: 40017537
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
 
LVL 35

Accepted Solution

by:
ste5an earned 2000 total points
ID: 40017564
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
 
LVL 1

Author Closing Comment

by:HLRosenberger
ID: 40017626
This worked perfect.  Thanks!
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I have a large data set and a SSIS package. How can I load this file in multi threading?
In the first part of this tutorial we will cover the prerequisites for installing SQL Server vNext on Linux.
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.

718 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question