lundi 2 novembre 2015

How to Remove the duplicates in SQL Table and concat other part

Let's Assume I have DataTable /SQL Table that represents employee information for example

which contains firstname,lastname,age,company,yearsofexperience,Degree

I want to combine information based on firstname,lastname,age

company,yearsofexperience,Degree must be concat into corresponding cell

firstname   lastname   age   company   yearsofexperience      Degree

john         muller     21    IBM           4years            MBA   
jan          tonny      22,   MSoft         1years            MS
martin       tata       21    apple         2years            PHD
john         Muller     21    sony          3years            MBA
james        muller     21    IBM           4years            PHD   
jan          tonny      22    Telsa         1years            BS     
martin       tata       21    sun           2years            MBA
james        Muller     21    TCS           3years            BS

Please find me way to remove the duplicate rows and make other data concat in particular column

For example in from above example I want combine the information present in the similar other 3 entries

firstname   lastname   age   company            yearsofexperience      Degree

john      muller        21   IBM,sony,              4years,3years,        MBA,MBA   
jan       tonny         22,  MSoft,Telsa            1years,1years         MS,BS
martin    tata          21   apple,sun              2years,2years         PHD,MBA
james     muller        21   IBM,TCS               4years,3years          PHD,BS

Right I am looking for what is best ways to implement this

Its good approach if I Split the Tables in to 2 different tables? may be based on Primary key match. we can concat other entries ?

Please help me out thanks(+1) in advance

Aucun commentaire:

Enregistrer un commentaire