I have been banging my head against the wall for a few hours on writing this query. I have two tables. I want to select the number of times a game has been played on a certain date but only count one game per user. For example Ping Ping was played 3 times in 2011, but only by 2 users, so the total I want to return is 2.
SESSIONS TABLE
DATE GAME_ID USER_ID
2011 1 1
2011 2 1
2011 1 1
2011 1 2
2011 2 2
2012 1 1
2012 1 1
GAMES TABLE
ID NAME
1 PING PONG
2 TENNIS
I have really struggled so far. This snippet returns the unique times but not limited to date.
SELECT DISTINCT GAME_ID,USER_ID FROM SESSIONS
I know how to limit queries to dates etc but struggling with the count across two columns, do I have to pass the query above into a count function?
Any help would be greatly appreciated!
Thanks