This is probably a newbie question (bear with me) but how can I calculate the average for a list of numbers using SQL and the
AVG function? I mean, I can add together numbers in SQL
How can I calculate the average of
4 without inserting them to a table first?
I have tried different kinds of variations like:
SELECT 2 AS foo UNION 3 AS foo UNION 4 AS foo foo integer 1 2 2 3 3 4
SELECT AVG(SELECT 2 AS foo UNION 3 AS foo UNION 4 AS foo)
ERROR: syntax error at or near "select"
I just can't seem to find the right syntax. I'm on PostgreSQL at the moment if it matters.