我的数据就像这样
wavelength reflectance
341.6 2.48
343.6 2.58
344.7 2.37
346.3 2.32
347.9 2.29
349.5 2.36
351.1 2.23
352.6 2.24
354.2 2.25
355.8 2.29
357.4 2.28
358.9 2.23
我想使用公式
公式
预期产出
tera
1.105655
我应该如何在PostgreSQL中执行此操作?我是PostgreSQL的初学者,如果有人知道的话告诉我。
答案 0 :(得分:0)
SELECT (SUM(r)/SUM(i)) AS tera FROM
((SELECT SUM(reflectance) AS r, 0 AS i FROM table WHERE wavelength BETWEEN 340 AND 345)
UNION
(SELECT 0 AS r, SUM(reflectance) AS i FROM table WHERE wavelength BETWEEN 350 AND 355))
AS total