1
CREATE VIEW grafico AS SELECT AVG(realizacao) , AVG(estima), AVG(fisiologica),AVG(seguranca),AVG(social) FROM necessidade;
I am trying to create a view that brings the average of five columns of the table needs, but I cannot create this view with the above query.
postgres says I’m using the AVG function more than once.
Follow my table need:
CREATE TABLE necessidade
(
id serial NOT NULL,
realizacao integer,
estima integer,
fisioologica integer,
seguranca integer,
social integer,
PRIMARY KEY (id)
)
thanks for the answer, I edited the question! I could explain this your answer better. I voted in your answer , it worked here!
– Pena Pintada
@Penapintada, the alias x represents the query of your table "need", and select is the query that gives me the average result (avg) of the selected columns. Through this query, I created a view and there was no error. To answer the questions, create a view with this query I gave example and tell me the result.
– Groot
I had already made a query like this a long time ago but I forgot what the query was like, thanks for the reply.
– Pena Pintada
just to complement and this is your error, to generate the view you will have to add the column name. I edited the initial answer to be complete.
– Groot