My Data由2500行2列组成
iner tert
41.6 7.19
43.1 7.06
44.5 4.02
45.6 3.81
45.9 7.85
46.2 5.02
47.1 6.12
52.6 5.12
61.1 8.19
68.2 10.14
72.1 12.41
79.8 6.19
81.1 7.18
描述- 选择最大tert值为max,最小tert值为min在43 ~ 79之间,应用公式
(max+min)/2+min as reip
- 选择最接近45的位置为r45,
- 选择最接近72的位置作为r72
700+(reip-r45)/(r72-r45)*40
- 输出值为repw
和我想显示reip值和repw值作为输出
我在PostGreSQL中试过了
Select (MAX(tert)+MIN(tert))/2+MIN(tert) as reip from table_name where iner between 43 and 79
这是工作,但我不知道应用这个reip值在700+(reip-r45)/(r72-r40)*40
在这个公式,以及如何得到输出值显示为reip和repw
我试过这个查询它不工作..
select reip, 700+(reip-r45)/(r72-r45)*40 as reipw
from (
select (MAX(tert)+MIN(tert))/2+MIN(tert) as reip, tert where iner=44.5 as r45, tert where iner=71.9 as r72
from table_name
where iner between 650 and 800
) as SE_23693370
请帮助我做这个任务在单一执行....,
你可以这样做:
select reip, reip+1 as example
from (
select (MAX(tert)+MIN(tert))/2+MIN(tert) as reip
from table_name
where iner between 43 and 79
) as SE_23693370
;
下面是一个工作示例:http://sqlfiddle.com/#!15/0ad8f/2