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