AllExperts > Using MS Access 
Search      
Using MS Access
Volunteer
Answers to thousands of questions
 Home · More Using MS Access Questions · Answer Library  · Encyclopedia ·
More Using MS Access Answers
Question Library

Ask a question about Using MS Access
Volunteer
Experts of the Month
Expert Login

Awards

About Us
Tell friends
Link to Us
Disclaimer

 
 
 
 
About Bob Heifler
Expertise
ALL MICROSOFT ACCESS DESIGN AND PROGRAMMING QUESTIONS 
Free Microsoft Access Tutorial Videos are available to you at my web site. Fifteen years of Microsoft Access experience allows me to answer most of your questions. Common question example files available here.


Experience
Microsoft Access programming since 1994. Support for all versions.

Publications
My Microsoft Access articles are published at:DailyAccessTips.com

Education/Credentials
UCLA GRAD, Member of Association of Database Developers

Awards and Honors
AccessToExcel.com has won several shareware awards for assisting analysts in moving data from MS Access to Excel.

Past/Present Clients
See some of my past clients here.

 
   

You are here:  Experts > Computing/Technology > Business Software > Using MS Access > Min Price as a Comparison / SQL

Using MS Access - Min Price as a Comparison / SQL


Expert: Bob Heifler - 7/8/2009

Question
Hi Bob,

I am working on an access database system to store product/price information and wanted to write a query to find the minimum price per product which I have managed to do after finding the answer here http://en.allexperts.com/q/Using-MS-Access-1440/2009/1/MS-Access-lowest-cost.htm

The query I have written is:

SELECT AA.ProductID, AA.[Supplier ID], AA.Cost
FROM ItemSupp AS AA
WHERE (((AA.Cost)=(SELECT MIN(Cost) AS MinPrice FROM ItemSupp WHERE ProductID = AA.ProductID)));

(Not sure why access put lots of extra brackets in?).

BUT, what I want to do now is to be able to add more into that in the form of "OR WHERE [Supplier ID] = "A5" for example so that I will get a list of the minimum prices that I can compare to prices from a given supplier (so I think I will have to GROUP BY ProductID?).

Thanks in advance for any help given.

Regards

Andrew  

Answer
Andrew,
Yes a group by on product ID and use the visual query grid.  Once you do that you can just use the build in (from the list) aggregate functions of min, max, avg, etc. You could even do additional grouping by SupplierID.

Bob Heifler

MyAccessProgram.com
DailyAccessTips.com

Contact at:
http://myaccessprogram.com/Contact.html

Find example files at:
http://myaccessprogram.com/Download.html

Find free video tutorials at:
http://myaccessprogram.com/Tutorial.html

Ask a Question


 
User Agreement | Privacy Policy | Kids' Privacy Policy | Help
Copyright  © 2008 About, Inc. AllExperts, AllExperts.com, and About.com are registered trademarks of About, Inc. All rights reserved.