Results 1 to 2 of 2
  1. #1
    levi84 is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Dec 2012
    Posts
    1

    Select columns in query for which other column has min value


    Hi, I have a beginners question about queries. I have a table containing 3 fields, product number, provider number, and price. For each product number there are several providers, with different prices. I want to make a query that contains the minimum price and the provider for each product. I know how to get the mininum price per product (just min of price and group by product number), but how do i get an extra column that gives me the number of the provider corresponding with the minimum price for this product? Thank you for your help!

  2. #2
    alansidman's Avatar
    alansidman is offline VIP
    Windows 7 32bit Access 2010 32bit
    Join Date
    Apr 2010
    Location
    Steamboat Springs
    Posts
    2,529
    I did this with two queries. Someone else may be able to offer a solution with one.
    Code:
    SELECT Table1.ProdNr, Min(Table1.Price) AS MinOfPrice
    FROM Table1
    GROUP BY Table1.ProdNr;
    
    SELECT Query1.ProdNr, Query1.MinOfPrice, Table1.ProvNr
    FROM Query1 INNER JOIN Table1 ON (Query1.MinOfPrice = Table1.Price) AND (Query1.ProdNr = Table1.ProdNr);

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 5
    Last Post: 03-29-2012, 09:21 PM
  2. Replies: 1
    Last Post: 03-14-2011, 10:04 AM
  3. Add new column in a select query
    By ysrini in forum Queries
    Replies: 3
    Last Post: 02-03-2010, 06:58 AM
  4. Replies: 0
    Last Post: 04-03-2009, 01:15 PM
  5. Replies: 0
    Last Post: 02-14-2007, 01:35 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums