Hi All,
I have a query which works like I want but it calculates AVG in the wrong way.
SELECT tbl_movies.movie_id, tbl_movies.movie_title, tbl_movies.movie_year, tbl_movies.movie_imdb, COUNT(tbl_users_comments.movie_id) AS 'users comments', AVG(tbl_users_comments.score) AS 'users average'
However, the AVG is calculated from all fields and if there is no value in the field (type Float) then the default there is 0 which of course I don't want to count. Is it possible that I can squeeze somewhere WHERE tbl_users_comments.score>0 - but only for that one field. I don't want to filter everything. It's a long table of movies and some of them will have average score, some of them won't, but I want to list them all.
Please help or ask any questions if it's not clear what I wrote here.
Thank you.
I have a query which works like I want but it calculates AVG in the wrong way.
SELECT tbl_movies.movie_id, tbl_movies.movie_title, tbl_movies.movie_year, tbl_movies.movie_imdb, COUNT(tbl_users_comments.movie_id) AS 'users comments', AVG(tbl_users_comments.score) AS 'users average'
FROM tbl_movies "&_
LEFT JOIN tbl_users_comments ON tbl_movies.movie_id = tbl_users_comments.movie_id
GROUP BY tbl_movies.movie_id, tbl_movies.movie_title, tbl_movies.movie_year, tbl_movies.movie_imdb
ORDER by tbl_movies.movie_title;
ORDER by tbl_movies.movie_title;
Please help or ask any questions if it's not clear what I wrote here.
Thank you.