Answer the question
In order to leave comments, you need to log in
PostgreSQL average per row?
maybe the question is simple, but Google is desperately trying to send me to find the average by column, but I need by row.
SELECT
"FH_09_Q" ,
"FH_10_Q" ,
"FH_11_Q" ,
("FH_09_Q" + "FH_10_Q" + "FH_11_Q"),
("FH_09_Q" + "FH_10_Q"+ "FH_11_Q")/3
FROM
"SC_Wonder"."TMining_New"
where "FMineObj_ID" = 16
and "FDate" ='2015-01-26'
SELECT
"FH_09_Q" ,
"FH_10_Q" ,
"FH_11_Q" ,
(COALESCE("FH_09_Q",0) + COALESCE("FH_10_Q",0) + COALESCE("FH_11_Q",0)) as sum,
(COALESCE("FH_09_Q",0) + COALESCE("FH_10_Q",0) + COALESCE("FH_11_Q",0))/3 as avg
FROM
"SC_Wonder"."TMining_New"
where "FMineObj_ID" = 16
and "FDate" ='2015-01-26'
Answer the question
In order to leave comments, you need to log in
You have serious architectural problems if you have built such a nightmare. This should be in a column of the attached table, not in 9000 columns.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question