I'm stuck on this one query. Here is my setup:
table 1 (shows)
- show_user
- show_count
table 2 (views)
- view_user
- view_views
table 3 (users)
- user
- user_name
What I need to is produce results that contain:
sum(show_count), count(view_views), user_name
So far I have tried the following:
select sum(s.show_count), count(v.view_views), u.user_name
from users u
left join shows s on u.user = s.show_user
left join views v on u.user = v.show_user
group by u.user
The query is taking an eternity to run and returns neither the right count nor the sum.
Individually, the following queries work properly:
select sum(show_count), show_user from shows group by show_user;
select count(view_view), view_user from views group by view_user;