Max query returning multiple fields

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am not sure why I am having so much dificulty right now...

I have a table with 3 fields and 200,000 records.

Fields are Supplier, Unit, Spend

Supplier is the Supplier's Name
Unit is the Unit that spent money
Spend is the amount of money that the Unit Spent with the Supplier

The table is already grouped

I would like to query this table to find out which unit spent the most with
each supplier...Results should have each supplier listed once along with the
unit that spent the most money with them and then how much that unit spent.

I am certain this is probably pretty easy and I am missing something, but
any assistance would be GREATLY Appreciated. Thanks in advance =)

-John
 
H0MELY said:
I am not sure why I am having so much dificulty right now...

I have a table with 3 fields and 200,000 records.

Fields are Supplier, Unit, Spend

Supplier is the Supplier's Name
Unit is the Unit that spent money
Spend is the amount of money that the Unit Spent with the Supplier

The table is already grouped

I would like to query this table to find out which unit spent the most with
each supplier...Results should have each supplier listed once along with the
unit that spent the most money with them and then how much that unit spent.


SELECT T.Supplier, T.Unit, T.Spend
FROM table As T
WHERE T.Spend = (
SELECT Max(X.Spend)
FROM table As X
WHERE X.Supplier = T.Supplier)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

create queries 7
Query Help 1
Cross Tab Brainteaser 6
query too slow 1
query very slow 5
Them delivery services - some good, some not so good 3
How to get the correct ranking from a query 2
Simple query?? 4

Back
Top