HELP!! Newbie stuck... [message #373087] |
Mon, 26 March 2001 22:46 |
Chris
Messages: 128 Registered: November 1998
|
Senior Member |
|
|
Using Oracle demo tables (and one or two others) trying to get display of customers with the highest and lowest total purchases. Can't figure out where to limit by MAX() or MIN(). Everything I try either displays all rows or fails (every possible common error message there is, I've gotten). Here's the query. Any help would be greatly appreciated.
1 SELECT name, area, phone, ename as "SALES REP", SUM(total) AS "TOTAL PURCHASES"
2 FROM demo.customer ca, demo.emp ea, demo.ord oa
3 WHERE ca.repid = ea.empno
4 AND oa.custid = ca.custid
5 AND 'TOTAL PURCHASES' = ALL
6 (SELECT MAX('TOTAL PURCHASES')
7 FROM demo.ord ob, demo.customer cb
8 WHERE oa.custid = ob.custid)
9* GROUP BY name, area, phone, ename, 'TOTAL PURCHASES'
Thank you!!
|
|
|