469,331 Members | 4,734 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,331 developers. It's quick & easy.

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 1254
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
1 post views Thread by CARIGAR | last post: by
reply views Thread by suresh191 | last post: by
1 post views Thread by haryvincent176 | last post: by
reply views Thread by Marylou17 | last post: by
1 post views Thread by Marylou17 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.