Question:

How to pull highest value under supplied value in SQL?

by  |  earlier

0 LIKES UnLike

Hey all,

I have a table with authority levels, 0, 100, 200, 300, etc. and I have a query which is being sent an user authority level such as 189. What I need to figure out is how can I pull the highest value under the supplied value.

For example:

User Authority Level = 190

Table entries:

10

100

150

190

210

350

Desired return:

190

I need to return the highest value that is still under the range, so for this case I need to return 190. I need the return set to be one line, so I can't return 190 and all the entries below it.

Is this possible in SQL?

THANKS in advance!

 Tags:

   Report

3 ANSWERS


  1. select max(value)

    from table

    where value <= :input_value

    Something like that should work


  2. i don't know whether it is correct or not but just try it out

    SELECT column FROM table

    WHERE mark>=190

    note:

    in the column place give the column name where you get the that values (10,100,150,190,210,350) and in the table place give your table name

    to know more details visit

    http://www.w3schools.com/sql/default.asp

  3. select MIN(value)

    from table

    where value >=  <input_value>

Question Stats

Latest activity: earlier.
This question has 3 answers.

BECOME A GUIDE

Share your knowledge and help people by answering questions.
Unanswered Questions