Finding the lowest value in a table greater than a certain value

前端 未结 6 963
臣服心动
臣服心动 2021-02-09 14:01

Say I have the following data

Name      Value
===============
Small        10
Medium      100
Large      1000

Imagine that these represent the

6条回答
  •  温柔的废话
    2021-02-09 14:23

    select a.newvalue from (
    select MIN(value) as newvalue, 1 as order  From table where value > @param
    union select MAX(value) as newvalue, 2 as order from table) A
    order by a.order
    

提交回复
热议问题