Thursday, August 1, 2013

Technique show multiple rows in one single row with comma separate without using Repeater Controls

For example you have two columns in database School and Grades  like below

School                Grade
======             ========

M105                    01
M105                    02
M105                    03
M105                    04
M205                    05
M205                    02                    
M205                    01


And if you want to show these as a comma separated values like

School                 Grade
=======             ========
M105                    01,02,03,04
M205                    01,02,05

To achieve this with out using the repeater control in report to avoid performance issues follow this technique by creating a data source query subject in FM and use that in the report.

Oracle:

select
SCHOOL.SCHOOL_CODE ,
( listagg(SCHOOL.GRADE_NUMBER_CODE,', ')  within group

(order by SCHOOL.GRADE_NUMBER_CODE))  AS "GRADE"

from
ODS.SCHOOL  SCHOOL

group by

SCHOOL.SCHOOL_CODE


Enjoy
Kishore


3 comments:

  1. I am trying to implement the same but getting an error in the FM
    RQP-DEF-0177 An error occurred while performing operation 'sqlPrepareWithOptions' status='-16'.
    UDA-SQL-0358 Line 3: Syntax error near "within".

    ReplyDelete
  2. Very informative post for Cognostm1 developers.You can also visit aststraining.com for Cognostm1 stuff.

    Cognostm1 Online Training
    Cognostm1 Training
    CognosBI Online Training

    ReplyDelete
  3. Informative and knowledgeable content, big thumps up for your article. Keep sharing more stuff like this creditcardgenerator

    ReplyDelete