473,396 Members | 1,608 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Select lowest number from multiple rows in SQL

I cannot quite figure out how to accomplish the following results.
My table is "Products" with the following fields:
ID Item Metal Size Price
1 Ring 18ctGold 4-7 $23.00
67 Ring 18ctGold 8-11 $30.00
70 Ring Silver 4-7 $10.00
75 Ring Silver 8-11 $15.00
I simply want to be able to show unique metal AND lowest price for each
metal; so, for above I would want to show rows with ID 1 and 70 only.
SELECT DISTINCT comes close but returns all distinct prices.

Would something like this call for sub-queries?
Any help from experts out there to figure this one is most appreciated.

Nov 13 '05 #1
2 5464
1. Create a query into this table.

2. Depress the Total button on the toobar (upper sigma icon.)
Access adds a Total row to the design grid.

3. Drag the Metal field into the grid.
Accept "Group By" in the Total row.

4. Drag the Price field into the grid.
In the Total row under this field, choose Min.

That's it.

If you actually wanted to bring in other fields as well, this article
explains 4 approaches:
Getting a related field from a GroupBy (total) query
at:
http://www.mvps.org/access/queries/qry0020.htm

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

<cs****@hotmail.com> wrote in message
news:11**********************@g47g2000cwa.googlegr oups.com...
I cannot quite figure out how to accomplish the following results.
My table is "Products" with the following fields:
ID Item Metal Size Price
1 Ring 18ctGold 4-7 $23.00
67 Ring 18ctGold 8-11 $30.00
70 Ring Silver 4-7 $10.00
75 Ring Silver 8-11 $15.00
I simply want to be able to show unique metal AND lowest price for each
metal; so, for above I would want to show rows with ID 1 and 70 only.
SELECT DISTINCT comes close but returns all distinct prices.

Would something like this call for sub-queries?
Any help from experts out there to figure this one is most appreciated.

Nov 13 '05 #2
Many thanks, Allen - my query is now finally working the way that I
needed it to!

Nov 13 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Ralph Freshour | last post by:
I have a question about the following PHP script - I got it off a web site tutorial on how to count users logged into your site - my question is the $PHP_SELF variable - it writes the name of the...
0
by: Christopher Key | last post by:
Hi, I currently have a fairly complex query that returns a variable number of rows, sorted by various criteria. I am trying to insert the result of this query into an additional table, along...
9
by: Rowland Hills | last post by:
I have a table which is returning inconsistent results when I query it! In query analyzer: If I do "SELECT * FROM TABLE_NAME" I get no rows returned. If I do "SELECT COL1, COL2 FROM...
6
by: Ben Hallert | last post by:
Hi guys, I'm trying to figure out what bone headed mistake I made on something I put together. I've got a form (named 'context') that has a variable number of select-multiple inputs on it. ...
10
by: AC Slater | last post by:
I have 1 table (out of many) that has very poor performance when performing a select into on. The select statement is called multiple times. We've found each call to take almost 1 second... we...
11
by: Neo Geshel | last post by:
I have an Access DB, from which I am going to pull images. Each image has an associated ID, but the ID's are not necessarily sequential (some images may have been deleted, leaving gaps in the list...
4
by: Ed L. | last post by:
I think I'm seeing table-level lock contention in the following function when I have many different concurrent callers, each with mutually distinct values for $1. Is there a way to reimplement...
2
by: sathyashrayan | last post by:
Dear group, I have a task where I have to fetch datas from mysql and display it in the multiple select list box. I have fetched the datas and it is getting diplayed correctly in the multiple...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.