Sorting By Subtotal Descending ?

The Brown Growler

Registered User.
Local time
Today, 17:56
Joined
May 24, 2008
Messages
85
Hi,

Would anyone please be able to advise me if it is possible to create a query that will produce output where the order is sorted by a subtotal descending?

I have a list of suppliers and their regional offices and wish to obtain a list of suppliers and regional offices where the list is in descending order of the supplier subtotal.

The fields in my table named T_Suppliers are:
[Supplier], [SupplierBranch], [SupplierBranchSpend]

For each Supplier I could have 1 or more SupplierBranch values, each SupplierBranch with spend on orders.

What I hope to do is to get a query that will subtotal the spend at the Supplier level and sort the output in descending order of this subtotal.

If possible, a further subsort by SupplierBranchSpend at the SupplierBranch level would be useful.


Rgds
Growlos
 
This one just does the SupplierBranch but it should give you the general idea.

SELECT [Supplier], [SupplierBranch], Sum([SupplierBranchSpend]) AS TotalSpend
FROM T_Suppliers
GROUP BY [Supplier], [SupplierBranch]
ORDER BY Sum([SupplierBranchSpend]) DESC;
 

Users who are viewing this thread

Back
Top Bottom