count the rows

Post questions here relative to DataStage Enterprise/PX Edition for such areas as Parallel job design, Parallel datasets, BuildOps, Wrappers, etc.

Moderators: chulett, rschirm, roy

Post Reply
arshi
Participant
Posts: 50
Joined: Wed Apr 18, 2007 5:12 am

count the rows

Post by arshi »

Hi,

I have the requirement like,

INPUT

COL1

ABC
ABC
XYZ
ABC
XYZ

I want the OUTPUT as,

COL2 COL3
ABC 3
XYZ 2

Can you tell how to implement in datastage.

Regards,
Arshi
gateleys
Premium Member
Premium Member
Posts: 992
Joined: Mon Aug 08, 2005 5:08 pm
Location: USA

Re: count the rows

Post by gateleys »

Aggregate based on Col1 and count.
gateleys
Minhajuddin
Participant
Posts: 467
Joined: Tue Mar 20, 2007 6:36 am
Location: Chennai
Contact:

Post by Minhajuddin »

If you have more than one column and you want other columns to be intact, you need to split it using a copy stage aggregate it on COL1 and then join it back with the original stream on COL1
Minhajuddin

<a href="http://feeds.feedburner.com/~r/MyExperi ... ~6/2"><img src="http://feeds.feedburner.com/MyExperienc ... lrow.3.gif" alt="My experiences with this DLROW" border="0"></a>
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post by DSguru2B »

If your source is a database you can select that column and a count(*) next to it, with the first column in the group by clause.
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
ag_ram
Premium Member
Premium Member
Posts: 524
Joined: Wed Feb 28, 2007 3:51 am

Post by ag_ram »

Minhajuddin wrote:If you have more than one column and you want other columns to be intact, you need to split it using a copy stage aggregate it on COL1 and then join it back with the original stream on COL1
Didn't see that Job type is Server, Minhajuddin.
pranay
Participant
Posts: 20
Joined: Mon Jan 09, 2006 3:34 pm

Post by pranay »

use the aggregator stage with columns COL1 and count(COL1).
Pranay
Seatte, WA
Minhajuddin
Participant
Posts: 467
Joined: Tue Mar 20, 2007 6:36 am
Location: Chennai
Contact:

Post by Minhajuddin »

My apologies for giving the wrong solution :oops:
Minhajuddin

<a href="http://feeds.feedburner.com/~r/MyExperi ... ~6/2"><img src="http://feeds.feedburner.com/MyExperienc ... lrow.3.gif" alt="My experiences with this DLROW" border="0"></a>
Post Reply