View Full Version : Select smallest number
ellisd5
01-07-2004, 07:00 PM
I have a access database
I want to select 1 row from this table where the column time, has the smallest value
How do I do this
TIA Dale
shmoove
01-07-2004, 08:19 PM
select * from SomeTable where SomeColumn = (select min(SomeColumn) from SomeTable)
shmoove
ellisd5
01-08-2004, 10:31 AM
Thanks for help but its still not quite working, this is what I got
select person, time
from 100METRES
where time = (select min(time) from100METRES)
shmoove
01-08-2004, 10:48 AM
It might be a simple type but there should be a space separating from and the table name in the subquery. This query might return more than one result if there is more than one record with the minimum time, so that should be taken into account.
How is it not working? Are you getting errors? Bad results? Some more info will help us help you.
shmoove
ellisd5
01-08-2004, 10:53 AM
Ok,
The error message that access brings up is tthis
Syntax error. in query expression 'time = (select min(time) from100METRES)'
Dale
shmoove
01-08-2004, 11:10 AM
Did you correct that typo? Cause I just opened up Access and it worked for me. The query should be
select person, time
from 100METRES
where time = (select min(time) from 100METRES)
Notice in the last line there is a space between "from" and "100METRES".
shmoove
ellisd5
01-08-2004, 11:17 AM
Yep it is workin without the typo.
It was me being thick, i was looking at the part of code where the first "FROM" is written. That has a space between it, I assumed that your browser was formating it and removing that space so you were seeing it differen't :o
Thanks for help
Dale
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.