minimum and maximum values

M

Mike

How can I query only those records with the minimum value
from field1 and maximum from field2? Spcifically I have a
table of road segments with address ranges along with
RoadName I want to simplify and query min and max
address...

Thanks, Mike
 
T

Tom Ellison

Dear Mike:

If you need to see what the minimum value of a column you can use just a
simple aggregate query:

SELECT MIN(SomeColumn) FROM SomeTable

If you want to see any other values from the row(s) that has/have this value
you will need a subquery:

SELECT Column1, Column2
FROM SomeTable
WHERE SomeColumn = (SELECT MIN(SomeColumn) FROM SomeTable)

If you want to see all the rows with either the minumum or maximum values (I
think that's what you said:

SELECT Column1, Column2
FROM SomeTable
WHERE SomeColumn = (SELECT MIN(SomeColumn) FROM SomeTable)
OR SomeColumn = (SELECT MAX(SomeColumn) FROM SomeTable)
 

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

Top