Hello Frndz,
I have a table named product as shown below:
product_id product_name
1 AAA
1 BBB
1 CCC
2 PPP
2 QQQ
2 RRR

Now my output should be:
product_id product_name_1 product_name_2 product_name_3
1 AAA BBB CCC
2 PPP QQQ RRR

Answer Posted / vishvajeet mistry

We can also use Full outer join in this case.

sel
t1.pid,
t1.pn as pn1,
t2.pn as pn2,
t3.pn as pn3
from
(sel pid,pn
from prod
qualify rank() over (partition by pid order by pn)=1)t1
Full outer join
(sel pid,pn
from prod
qualify rank() over (partition by pid order by pn)=2)t2
On
t1.pid=t2.pid
Full outer join
(
sel pid,pn
from prod
qualify rank() over (partition by pid order by pn)=3)t3
on
t1.pid=t3.pid
order by 1 ;


Hope it helps :)

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What do you mean by teradata intelliflex?

634


How do you verify a complicated sql?

635


how many modules are there in telecome domain?how to explain the architecture?

1561


If Fast Load Script fails and only the error tables are made available to you, then how will you restart?

637


Highlight the points of differences between the database and user in Teradata.

593






What is oltp?

574


Differentiate primary key and partition key?

582


What are the various etl tools in the market?

587


If the PMON is not working then how do you identify and monitor all the processes, resources and sessions ?

1745


Why teradata is used?

581


Explain and compare pros and cons of start schemas?

549


Difference between star and snowflake schemas?

609


What is the opening step in basic teradata query script?

600


In general, how do you optimze any sql in teradata?

554


Explain fallback in teradata?

612