Concat LID with a Seq Sting and make all Seq String in one cell and for the unique LID

it shows duplicates for LID. How can I Concat or make the LID unique but will contain all the Seq in each call for each LID?

Desired Results
Lid, Seq
1 , A,B,C,D,E

Currently,
Concat and sequence
Table A has contains the
Field/Column LID in integer
Field/Column SEQ in Text or String

LID contains values like 1,2,3,4,5, and so forth
SEQ contains values like A,B,C,D,E and so forth

Current results
when queried
select all from Table A
it can show
Lid, Seq
1 A
1 B
1 D
1 E

STRING_AGG (Transact-SQL) - SQL Server | Microsoft Learn

1 Like

hi

hope this helps

create data script

declare @data table ( Lid int , Seq varchar(1))

insert into @data select 1, 'A'
insert into @data select 1, 'B'
insert into @data select 1, 'D'
insert into @data select 1, 'E'

insert into @data select 2, 'A'
insert into @data select 2, 'D'

select 
   LID 
 ,string_agg(Seq,',') 
from 
    @data 
group by 
    LID

[
harishgg1
Thank you