Sorry, I misread the question...

Still, I think min/max are better than order by limit 1.

Wes

On Mon, Jul 13, 2009 at 7:24 PM, Wes Freeman<[email protected]> wrote:
> Select max(number), min(number) from table;
>
> Wes
>
> On Mon, Jul 13, 2009 at 7:16 PM, Bogdan Nicula<[email protected]> wrote:
>>
>>
>> Hi,
>>
>> Sorry for my lack of SQL knowledge which triggered this help request:
>> Given a column containing numbers, which is the most efficient manner to 
>> find out the highest smaller and lowest greater number?
>> That is, is there a better way than:
>>
>> select * from table where number <= ? order by number desc limit 1;
>> select * from table where number>= ? order by number asc limit 1;
>>
>>
>> What if the table contains millions of rows?
>>
>> Thank you for any help,Bogdan
>> _________________________________________________________________
>> Show them the way! Add maps and directions to your party invites.
>> http://www.microsoft.com/windows/windowslive/products/events.aspx
>> _______________________________________________
>> sqlite-users mailing list
>> [email protected]
>> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
>>
>
_______________________________________________
sqlite-users mailing list
[email protected]
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to