描述
选择波长接近740的反射率为r740
应用公式
700+(辐射-R700)/(R740-R700)* 40
输出值为radtera,我想显示辐射值和radtera值作为输出
我尝试了这个查询,它在辐射中显示了很多值,它在radtera中显示了许多空值,但我只想显示一个辐亮度值和一个radtera值
SELECT radiance, (700+(radiance-r700))/((r740-r700)*40) as radtera
FROM (
SELECT (MAX(reflectance)+MIN(reflectance))/2+MIN(reflectance) as radiance,
case when wavelength=700 then reflectance end as r700,
case when wavelength=740 then reflectance end as r740
FROM table_name
WHERE wavelength between 650 and 800
GROUP BY wavelength,reflectance
) AS SE_23693370
如果我删除
GROUP BY波长,反射率
这来自查询,它显示错误
这是SQL fiddle。
我检查了一下,我不知道它是如何显示许多值而不是一个值显示..任何人帮我纠正错误请...
我尝试在SQL fiddle中使用案例陈述。
select reip,700+(reip-r45)/(r72-r45)*40 as reipw
from (
select (mx+mn))/2+mn as reip
from (
select case max(tert) as mx,
case min(tert) as mn
case when iner=44.5 then tert end as r45,
case when iner=72.1 then tert end as r72
from table_name
where iner between 43 and 79)bar
)as SE_23693370
它显示*错误:FROM中的子查询必须有一个别名:select select,700 +(reip-r45)/(r72-r45) 40作为从(select(mx + mn))/ 2+的重入mn作为reip from(选择case max(tert)作为mx,case min(tert)作为mn情况,当iner = 44.5然后tert结束为r45,情况当iner = 72.1然后tert结束作为r72来自table_name,其中iner在43和79之间))作为SE_23693370
答案 0 :(得分:0)
您可以使用ROW_NUMBER
功能执行此操作。它可以在SQL Server,Oracle和PostgreSQL等处使用。
select radiance, r700, r740,
(700+(radiance-r700))/((r740-r700)*40) as radtera
from
(select t.reflectance as radiance,
t700.wavelength as r700, t740.wavelength as r740
from
(select max(reflectance) as reflectance
from table_name) t,
(SELECT reflectance, wavelength,
row_number() over (order by abs(wavelength-700)) as rn700
FROM table_name
WHERE wavelength between 650 and 800) as t700,
(SELECT reflectance,wavelength,
row_number() over (order by abs(wavelength-740)) as rn740
FROM table_name
WHERE wavelength between 650 and 800) as t740
where t700.rn700=1 and t740.rn740=1) as di