1

I have a question regarding how to merge lines with same characteristics:

I have this data:

Client | Product | Date

Hannah | TV | 1 Jan

Tom | Laptop | 3 Feb

Peter | iPod | 2 Jan

Hannah | Laptop | 5 Feb

Tom | iPod | 5 Feb

And I want to create this:

Client | Product-History|

Hanna | TV-Laptop |

Tom | Laptop-iPod |

Peter | iPod |

Anyone know if this is possible in SQL?

If you require actual SQL code to make it easier to respond let me know, it's the first time I ask a question.

Thanks!

Edit: I am using SQL Server

Frazz
  • 2,995
  • 2
  • 19
  • 33

2 Answers2

0
select client,group_concat(product) 
from tablename group by client
Light
  • 375
  • 4
  • 11
0

You can Try This query:

SELECT client,group_concat(product) as Product-History
from YOUR_TABLE  group by client
Ankit Bajpai
  • 13,128
  • 4
  • 25
  • 40