 |
 |
Archives of the TeradataForum
Message Posted: Mon, 12 Jan 2004 @ 21:04:35 GMT
Subj: | | Re: How to concatenate the column values |
|
From: | | Babu, Mahesh |
If you know the C2 values before hand, you can achieve this one by using a straight SQL like this.
SELECT
C1,
max(case when c2 = value1 then c2 else '' end)||
max(case when c2 = value2 then c2 else '' end)||
max(case when c2 = value3 then c2 else '' end)||
max(case when c2 = value4 then c2 else '' end)
from table
group by 1;
If you don't know the values, then using CSUM and a derived table will do the trick.
SELECT
C1,
max(case when rnk = 1 then c2 else '' end)||
max(case when rnk = 2 then c2 else '' end)||
max(case when rnk = 3 then c2 else '' end)||
max(case when rnk = 4 then c2 else '' end)||
-
-
-
from
(select c1,c2,csum(1,c2) rnk from table
group by 1) derived
group by 1;
Thanks
Mahesh
| |