|
|
Archives of the TeradataForum
Message Posted: Mon, 30 Sep 2002 @ 17:34:21 GMT
Subj: | | Re: Data transposition |
|
From: | | Babu, Mahesh |
Here is an example with using RANK function.
select t1.name,t1.acctno,t2.telno,t3.telno,t4.telno
from
(select name,acctno
from table1
group by 1,2) t1
left outer join
(select name,acctno,telno,rank(telno) rnk
from table1
group by 1,2) t2
on t1.name = t2.name and
t1.acctno = t2.acctno and
t2.rnk = 1
left outer join
(select name,acctno,telno,rank(telno) rnk
from table1
group by 1,2) t3
on t1.name = t3.name and
t1.acctno = t3.acctno and
t3.rnk = 2
left outer join
(select name,acctno,telno,rank(telno) rnk
from table1
group by 1,2) t4
on t1.name = t4.name and
t1.acctno = t4.acctno and
t4.rnk = 3
Mahesh Babu
Pleasanton. CA-94588
| |