Solved

help with SQL

Posted on 2014-04-23
4
540 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 34

Accepted Solution

by:
ste5an earned 500 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

Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

Question has a verified solution.

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

How to leverage one TLS certificate to encrypt Microsoft SQL traffic and Remote Desktop Services, versus creating multiple tickets for the same server.
Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
Via a live example, show how to shrink a transaction log file down to a reasonable size.

734 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