I have two tables:
Table user_ratings
id home_info_id ratings
1 1 3.5
2 2 3.5
3 1 4
4 1 5
5 1 2
6 2 1
7 2 4
Table home_info
:
id home_name
1 my_home
2 ur_home
3 his_home
As you can see 'my_home' and 'ur_home' has ratings but 'his_home' is not rated yet. I am calculating the avg of all homes, so I am getting avg of only two homes, i.e. 'my_home' and 'ur_home', as I said 'his_home' is not rated yet, so I am not getting 'his_home' in my query below. I want all the names of homes which are not rated yet. Here is my query:
select u.home_info_id
, avg(u.ratings)
, h.home_name
from user_ratings u
, home_info h
where h.id = u.home_info_id
group by u.home_info_id
, h.home_name;
The output is something like this:
home_info_id ratings home_name
1 4.83 my_home
2 2.83 ur_home
But I want something like this:
home_info_id ratings home_name
1 4.83 my_home
2 2.83 ur_home
3 0 his_home