Answer the question
In order to leave comments, you need to log in
Postgres average of two columns?
I have a table to store values. that is, one analysis corresponds to several elements with values
SELECT
elem_id,
analiz_id,
value
FROM
vgok_site.a_analiz_data
where analiz_id = 26;
Answer the question
In order to leave comments, you need to log in
if I understand you correctly
select cast(x.number as real) / cast(y.number as real)
from
(
SELECT value as number from a_analiz_data where id = 6
) x
join
(
SELECT value as number from a_analiz_data where id = 5
) y on 1=1
You can add them to a query condition like "WHERE analiz_id = 26 AND elem_id IN (5,6)" and get the value via AVG()
SELECT
AVG(value)
FROM
vgok_site.a_analiz_data
where analiz_id = 26 AND elem_id IN (5,6) ;
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question