
Complex SQL Query...HELP!
Hello,
I am having tons of problems formulating this query: Say I am a librarian,
I want to find the cheapest supplier of each book I have:
Sample Table Data: TableName: Supplier
Name ISBN Price
======= ======= =======
ABC 100 $5.99
XYZ 100 $7.99
ABC 200 $1.99
XYZ 200 $1.50
ABC 300 $2.95
XYZ 300 $3.75
Running the SQL Query should return the following:
Sample Correct Output: (This is what I am trying to achieve)
Name ISBN Price
======= ======= =======
ABC 100 $5.99
XYZ 200 $1.50
ABC 300 $2.95
What I have so far is not working 100% :
SELECT Name, ISBN, Min(Price) AS MinOfPrice FROM Supplier GROUP BY Name, ISBN
ORDER BY Min(Price)
The output of the above query is:
Name ISBN Price
======= ======= =======
ABC 100 $5.99 (GOOD)
XYZ 200 $1.50 (GOOD)
ABC 300 $2.95 (GOOD)
XYZ 100 $7.99 (GO AWAY!)
ABC 200 $1.99 (GO AWAY!)
XYZ 300 $3.75 (GO AWAY!)
How do I change the above query (or simply make a new one) which gives me
my desired output?
I'm using VB 4.0 Enterprise if that matters (shouldn't).
Thanks again
Deepak