Teradata Query

Database
Enthusiast

Teradata Query

I have data in Apps Table as:

(app_id,store_id,mail_id)
(1,111,'abc.com')
(1,111,'def.com')
(2,222,'krk.com')
(2,222,'gfh.com')

How could I obtain the output in this format:

(app_id,store_id,mail_id)
(1,111,'abc.com,def.com')
(2,222,'krk.com,gfh.com')
Tags (1)
1 REPLY
Enthusiast

Re: Teradata Query

select x.col1,x.col2,max(x.newcol3),max(x.newcol4) from
(
select col1,col2,col3,case row_number() over(partition by col1,col2 order by col3 desc) when 1 then col3 else null end newcol3,
case row_number() over(partition by col1,col2 order by col3 desc) when 2 then col3 else null end as newcol4
from u1.t1)x group by x.col1,x.col2;