472,131 Members | 1,326 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

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

greatest value bounded above?

Hi, I'm looking for an efficient way to do the following:

"given a column of entries with double values, select the greatest
value less than D", where D is given as the upper bound.

so if I have 0.1, 1.4, 10.11, 5.5 etc. then for D = 5, i should get
1.4.

My current solution stores all entries in an array and sorts them...
which I know is very very very inefficient.

Dec 23 '05 #1
2 1294
stupid stupid me!:

select * from TABLE where value>0.0 and value<D order by value desc
limit 1;

ok, this works for me. thanks for reading!!!!

Shark wrote:
Hi, I'm looking for an efficient way to do the following:

"given a column of entries with double values, select the greatest
value less than D", where D is given as the upper bound.

so if I have 0.1, 1.4, 10.11, 5.5 etc. then for D = 5, i should get
1.4.

My current solution stores all entries in an array and sorts them...
which I know is very very very inefficient.


Dec 23 '05 #2
SELECT
MAX(Number)
FROM
NUMBERS
WHERE
Number < 5

Rich
"Shark" <cp*******@yahoo.com> wrote in message
news:11*********************@g44g2000cwa.googlegro ups.com...
Hi, I'm looking for an efficient way to do the following:

"given a column of entries with double values, select the greatest
value less than D", where D is given as the upper bound.

so if I have 0.1, 1.4, 10.11, 5.5 etc. then for D = 5, i should get
1.4.

My current solution stores all entries in an array and sorts them...
which I know is very very very inefficient.

Dec 24 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by zaceti | last post: by
9 posts views Thread by ckerns | last post: by
8 posts views Thread by Mike Nolan | last post: by

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.