kingberrill of SQL
7/2/2017 - 8:10 PM

AVG()

AVG()

-- To get the average value of a numeric column use the AVG() function.

SELECT AVG(<numeric column>) FROM <table>;
SELECT AVG(<numeric column>) FROM <table> GROUP BY <other column>;


-- get average cost by users
SELECT AVG(cost) AS average FROM orders GROUP BY user_id;