开发者

SQL get the value above(larger) and below(smaller) of an inbetween value in a select statement

开发者 https://www.devze.com 2023-03-18 10:03 出处:网络
I have a table containing two columns \"allowable\" and \"thickness\". The thickness values are let say 1.2234,3

I have a table containing two columns "allowable" and "thickness".

The thickness values are let say 1.2 2 3 4,3 I'm trying to write a udf which can take any thickness (eg2.3) and then it interpolates the allowable values. My question is 开发者_JS百科if there is a smart (or maybe even out of the box) function which returns the upper and lower thickness value I need (2 and 3). Regards, Lumpi I'm using ms sql server 2008..


select 'max', max(thickness) value from thicknesses where thickness < requirement 
union
select 'min', min(thickness) value from thicknesses where thickness > requirement 
0

精彩评论

暂无评论...
验证码 换一张
取 消