472,131 Members | 1,326 Online

# 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
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.