Quantcast
Channel: ฟอรัม Getting started with SQL Server
Viewing all articles
Browse latest Browse all 8428

Help in SQL database remove duplicate fields

$
0
0
I have different tables like Employee, mentor_offer, department and criteria.  Employee has all the employee details and department has the id and name of all the departments, Criteria has id and name of all the skills. Mentor_offer has the email id and the skill for that particular email id.

The stored procedure that i am using is 

SELECT distinct e.firstName + ' ' + e.lastName as name, e.email, e.geo,c.name as skill, d.name as department, e.addedDate, e.modifiedDate 
from employee e 
inner join mentor_offer m 
on e.email=m.email
inner join department d
on e.department = d.id
inner join criteria c 
on m.criteria_id = c.id
order by e.addedDate desc

At present I get the result like this:


Name|Email|Location|Department|Skill|addedDate|mod ifiedDate
-----------------------------------------------------------
Arun Rao|arun@test.com|NA| Marketing|Planning & Organizing| 3/17/2014 1:01:21 PM|3/20/2014 2:37:50 PM
Arun Rao|arun@test.com|NA| Marketing|Technical Skills| 3/17/2014 1:01:21 PM|3/20/2014 2:37:50 PM
Binay|binay@test.com|NA|Sales|Leadership|3/17/2014 1:01:21 PM|3/20/2014 2:37:50 PM
Binay|binay@test.com|NA|Sales|Technical Skills|3/17/2014 1:01:21 PM|3/20/2014 2:37:50 PM

Expected Result:
 I would like to add the skills in a single row with comma separated and remove the duplicate entries of Name, Email ,Location, Department. 

Name|Email|Location|Department|Skill|addedDate|mod ifiedDate
-----------------------------------------------------------
Arun Rao|arun@test.com|NA| Marketing|Planning & Organizing, Technical Skills|3/17/2014 1:01:21 PM|3/20/2014 2:37:50 PM
Binay|binay@test.com|NA|Sales|Leadership, Technical Skills|3/17/2014 1:01:21 PM|3/20/2014 2:37:50 PM

Please help.



Viewing all articles
Browse latest Browse all 8428

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>