Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

concatenate column data group by another column

Status
Not open for further replies.

CrystalProgDev

Programmer
Oct 1, 2010
69
US
I have a data set some thing like this

Num Code_1 Code_2
1 1230 A12
1 1230 C13
1 1230 B14
2 1230 R115
3 1234 A12
3 1234 A13
4 1124 NULL
5 1234 D1
I need to conacatenete code_2 data in the report group by Num as below.

Num Code_1 Code_2
1 1230 A12,C13,B14
2 1230 R115
3 1234 A12,A13
4 1124
5 1234 D1

Can any one help me. It is urgent. Thank you in advance.
 
Insert a group on num, and then create formulas like these:

//{@reset} for the num group header:
whileprintingrecords;
stringvar x;
if not inrepeatedgroupheader then
x := "";

//{@accum} for the detail section:
whileprintingrecords;
stringvar x;
if not isnull({table.code_2}) then
x := x + {table.code_2}+"," else
x := x;

//{@display} for the num group footer:
whileprintingrecords;
stringvar x;
if len(x)>1 then
left(x,len(x)-1);

Suppress the detail section and drag the groupname and the code_1 field into the group footer next to {@display}.

-LB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top