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
Where is teradata rdbms used?
What are the scenarios in which full table scans occurs?
How do you define Teradata?
What is spool space and when running a job if it reaches the maximum spool space how you solve the problem?
Why do you get spool space errors? How do trouble-shoot them?
What is the difference between global temporary tables and volatile temporary tables?
What are the steps involved after the disk manager passes the request?
Explain some differences between mpp and smp?
Explain the term 'database' related to relational database management system?
What is the purpose of joins in teradata?
How you will check the version of teradata?
Did you write stored procedures in teradata?
What is stored procedure in teradata?
What are different table types used in teradata?
What are the frequently used data types in teradata?