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
Solved

help with SQL

Posted on 2014-04-23
4
532 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
  • 2
4 Comments
 
LVL 34

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 33

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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

In this article I will describe the Backup & Restore method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
Slowly Changing Dimension Transformation component in data task flow is very useful for us to manage and control how data changes in SSIS.
Via a live example, show how to extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.
Viewers will learn how to use the UPDATE and DELETE statements to change or remove existing data from their tables. Make a table: Update a specific column given a specific row using the UPDATE statement: Remove a set of values using the DELETE sā€¦

840 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