Displaying the highest value after a SUM query

First off thanks for reading - my first post here after trying to figure out Oracle!!

I have a few tables set up and the data inserted.
I have to set up a query that totals up the sales at various branches and then spits out which outlet has the best sales.

I used this query:

COMPUTE SUM OF dam_cost ON branch_no
BREAK ON branch_no SKIP 2
SELECT member.branch_no, dam_cost
FROM damage
INNER JOIN damage_type
ON damage.damage_code = damage_type.dam_type
INNER JOIN breakdown
ON damage.breakdown_id = breakdown.breakdown_id
ON breakdown.member_id = member.member_no
ORDER BY branch_no;

This results in a list that displays the branch number, the sales it has had and the sum of the sales. Now, how would I get the query just to display the branch with the highest sales???

I thought it would be fairly simple with the MAX() command, but I was wrong!

Thanks again and any help appreciated on the problem!!

Ry (Oracle newbie!!)
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!