minimum and maximum values

  • Thread starter Thread starter Mike
  • Start date Start date
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
 
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)
 
Back
Top