how to get TOP 5 sums

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
Devendrudu
Participant
Posts: 31
Joined: Tue May 24, 2011 12:16 am

how to get TOP 5 sums

Post by Devendrudu »

Hi Friends,

i have two files
f1 have cust_id,Tran_id,sales_amount

f2 have cust_id,cust_name

i want o/p like cust_name, Total_sales_amount

I want only top 5 Total_sales_amount customers.


how can do this?
Devendra,Bangalore,India
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Join the two, sort the result by the amount descending and constrain the output to the first five records. Note you'll need to run sequentially or on one node for this to work properly.
-craig

"You can never have too many knives" -- Logan Nine Fingers
Devendrudu
Participant
Posts: 31
Joined: Tue May 24, 2011 12:16 am

Post by Devendrudu »

if it run in 2node or 4node how will get top 5 sums
Devendra,Bangalore,India
soumya5891
Participant
Posts: 152
Joined: Mon Mar 07, 2011 6:16 am

Post by soumya5891 »

In the sort stage you need to perform a hash partioning properly
Soumya
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

You'll get the Top 5 sums per node unless you throttle things down to sequential execution, hence my suggestion.
-craig

"You can never have too many knives" -- Logan Nine Fingers
Devendrudu
Participant
Posts: 31
Joined: Tue May 24, 2011 12:16 am

Post by Devendrudu »

which key i want to hash partition.
Devendra,Bangalore,India
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post by DSguru2B »

The answer lies in this statement
Devendrudu wrote: I want only top 5 Total_sales_amount customers.
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
Post Reply