COGNOiSe.com - The IBM Cognos Community

IBM Cognos 8 Platform => COGNOS 8 => Report Studio => Topic started by: hiranb on 25 Feb 2009 09:33:26 AM

Title: concatenate strings from a column into a single row in cognos
Post by: hiranb on 25 Feb 2009 09:33:26 AM
Hi,
I have to  concatenate strings from a column into a single row

id    test  score  NEWDATAITEM
id1   A       1       121
id1   B       2       121
id1   C       1       121

Thanks for your help.

Hiran

Title: Re: concatenate strings from a column into a single row in cognos
Post by: blom0344 on 26 Feb 2009 12:41:26 PM
Bringing the test object will always generate 3 rows, no matter if you could concatenate the score

In SQL terms:


SELECT ID,(CAST(S1 AS VARCHAR(10))+(CAST(S2 AS VARCHAR(10))+(CAST(S3 AS VARCHAR(10))) AS STRING FROM
(SELECT ID,SUM(CASE WHEN TEST = 'A' THEN SCORE ELSE 0 END) AS S1,
SUM(CASE WHEN TEST = 'B' THEN SCORE ELSE 0 END) AS S2,
SUM(CASE WHEN TEST = 'C' THEN SCORE ELSE 0 END) AS S3
GROUP BY ID) TEMP