I have this querys:
SELECT COUNT(genre) AS Total
SELECT SUM(rating) AS SUMX
The querys are working well separately, but now i want the result= SUMX/Total
Genre |SUMX |TOTAL |RESULT
Animation 6 2 3
Anyone knows help me?
SELECT genre, SUM (rating) AS TOTAL_SUM, COUNT(genre) AS TOTAL_GENRE, SUM(rating)/COUNT(genre) AS Total
GROUP BY genre
you can replace COUNT(genre) with COUNT(*) since genre will never be NULL in this query
you can also replace SUM(rating)/COUNT(genre) with AVG(rating)
This topic is now closed. New replies are no longer allowed.