maximum profit from overall branch

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
mcs_dineshm
Participant
Posts: 12
Joined: Sun Sep 23, 2007 12:21 am
Location: chennai

maximum profit from overall branch

Post by mcs_dineshm »

I am having five branches and my query is to caluclate the maximum profitable branch.By using aggregator,br_id as group key i am getting 5 rows with maximum profit of each branch,but i need only one row containing the most profitable branch among all the branches to be displayed.. Can anyone solve my query.....
dineshm
Maveric
Participant
Posts: 388
Joined: Tue Mar 13, 2007 1:28 am

Post by Maveric »

Max function in sql would help.
mcs_dineshm
Participant
Posts: 12
Joined: Sun Sep 23, 2007 12:21 am
Location: chennai

Post by mcs_dineshm »

No,i need in datastage
dineshm
Maveric
Participant
Posts: 388
Joined: Tue Mar 13, 2007 1:28 am

Post by Maveric »

Sort data on profit field in descending order and take only the first row from the output.
Ronetlds
Participant
Posts: 28
Joined: Thu Mar 30, 2006 12:48 pm

Post by Ronetlds »

Maveric wrote:Sort data on profit field in descending order and take only the first row from the output.
Try maximum function in aggregator stage :wink:
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

DataStage was never intended to be a reporting tool. Why are you trying to use the wrong tool?
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Ronetlds
Participant
Posts: 28
Joined: Thu Mar 30, 2006 12:48 pm

Post by Ronetlds »

My guess is management decree. They paid for it, ergo you must use it. I've actually worked in a situation where the push was to convert EVERY server job to EE even though we were chugging through a whopping 20,000 rows max per job. Feeling nauseous yet? :P
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Push back against illogical decrees. Always. Otherwise you're asking for grief. Explain the downside(s), and get them to put their signature on a document you've prepared containing these explanations and the assertion that they want things done their way irrespective. At least then you can shift the blame when that becomes necessary. And it will.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
mcs_dineshm
Participant
Posts: 12
Joined: Sun Sep 23, 2007 12:21 am
Location: chennai

Post by mcs_dineshm »

Hi friends, i cant use aggregator stage as i'm having five different branches so it'l give five branch details as i'm gouping by branch id. but i need only the branch with which is most profitable alone. And also i cant use sorting and get the first data alone as there wil be a problem if two branches have the same maximum profit..
dineshm
mcs_dineshm
Participant
Posts: 12
Joined: Sun Sep 23, 2007 12:21 am
Location: chennai

Post by mcs_dineshm »

hi ray can u tel me wat does a reporting tool does actually, and wat the datastage should do, as u said i'm using a wrong tool... I'm having a query to find the maximum profitable branch out of five branches, if its possible to execute this query in sql why not in datastage..
dineshm
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Nobody said it was not possible in DataStage. The point was that you are using a sledgehammer to repair a watch. If it can be done in SQL, do it in SQL. DataStage can issue the SQL, if you must, but it would be better using a reporting tool, either a database client tool or a business intelligence tool.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

mcs_dineshm wrote:Hi friends, i cant use aggregator stage as i'm having five different branches so it'l give five branch details as i'm gouping by branch id. but i need only the branch with which is most profitable alone. And also i cant use sorting and get the first data alone as there wil be a problem if two branches have the same maximum profit..
So? In either SQL or DataStage you'll need to 'aggregate' to compute your value and then sort descending to get the branch with the highest value. Constrain it to take only the first row post-sort if you always need to pick one, or use stage variables to constrain your output to all of the first rows with the same max value.

Or, as noted, do this in your BI / reporting tool (if you have one) which is exactly what function *it* was purchased for.
-craig

"You can never have too many knives" -- Logan Nine Fingers
Post Reply