Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/sql/75.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/postgresql/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Sql 在单个公式中执行多个任务_Sql_Postgresql - Fatal编程技术网

Sql 在单个公式中执行多个任务

Sql 在单个公式中执行多个任务,sql,postgresql,Sql,Postgresql,我的数据由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值作为最大值,选择最小tert值作为最小值,其中 iner介于43和79之

我的数据由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值作为最大值,选择最小tert值作为最小值,其中 iner介于43和79之间,并将公式
    (max+min)/2+min应用为reip
  • 选择更接近45的tert作为r45,然后
  • 选择接近72的tert作为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 
;

这里是一个工作示例:

先生,我想从我已经尝试过的公式中获取reip的值,并将该值应用于这个公式700+(reip-r45)/(r72-r40)*40执行repw的第一次查找reip和第二次查找输出后,然后我想显示reip和reipw的值。。。SE_23693370-意味着什么?你怎么用这个?它在应用公式后提供的输出给出了错误的值将您自己的公式(使用reip)放在它有
reip+1
的地方。这只是一个例子。我不能全部为你做。如何使用这个选择语句**选择波长=41.6的反射率作为r42**,以及**选择波长=72.1的反射率作为r72**在第二个公式中,并在单个公式中应用execution@Crescent月亮先生,如何在一次执行中完成这项任务…我在不同的查询中尝试了它,它的工作,如何在单个查询中完成此任务execution@Arion先生,请帮助我如何在一次执行中完成此任务。。。