Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Database > Oracle
|
Oracle General Oracle database discussions.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Oracle section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old December 9th, 2004, 10:36 AM
ry ry is offline
Registered User
 
Join Date: Dec 2004
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Finding the highest value of a 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:

Code:
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
INNER JOIN member
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!!)
 
Old December 18th, 2004, 12:40 PM
Authorized User
 
Join Date: Nov 2004
Posts: 30
Thanks: 0
Thanked 0 Times in 0 Posts
Default

SELECT * FROM
(YOUR_EXISTING_QUERY)
WHERE ROWNUM=1






Similar Threads
Thread Thread Starter Forum Replies Last Post
Selecting highest count stolte XSLT 2 November 19th, 2008 04:00 PM
finding highest value Aprile Access VBA 3 October 3rd, 2007 07:13 AM
Finding the highest amount keithd Excel VBA 2 May 25th, 2005 01:44 PM
Display highest test score kgs51 VB.NET 2002/2003 Basics 15 November 19th, 2004 11:02 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.