Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations MikeeOK on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Sort rows by $ amount

Status
Not open for further replies.

milton747

Programmer
Apr 21, 2005
133
US
Hi Folks,

The initial SQL (below) sums $ purchases by customer then by Item code.


SELECT customers.custID, items.itemcode,
( Sum (items.pricequote * items.quantity ) ) As gt
FROM customers, orders, items
WHERE customers.custID = orders.custID
AND orders.orderID = items.orderID
GROUP BY customers.custID, items.itemcode
ORDER BY customers.custID, items.itemcode, 3

Gets.........


ITEM CODE CID $ AMOUNT
MPL1632 101 430563
MR3280 101 60564
MSL3280 101 302610
MSL3290 101 430200

MP1608x 102 6048
MP2032 102 13640
MPL1632 102 165062

Order is CID, ITEM CODE. But I need to present the data order by dollar amount. (Big $ numbers first).


Thanks for any help to fix the SQL.
Milt.
 
ORDER BY 3 DESC, customers.custID ASC, items.itemcode ASC

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top