The following sql will return a count of how many users have played a game from the game sessions table.
SELECT count(DISTINCT `userID`) as count FROM `game_sessions`
In this table “game_sessions”, each row contains the details of a session of a user. Therefore there could be 3, 40 or even 500 rows with the same “userID”. I understand the above query will find out how many distinct values of “useriD” there is, or in other terms, how many people have played AT LEAST ONE game.
How can I modify this query so I can find out how many people have played AT LEAST TWO games or AT LEAST 30 games, thus seeing how many userID’s are repeated 2 times, 5 times, 10 times etc etc
You don’t need to use
DISTINCTkeyword on this, justCOUNTthe records based on the eachuserID. try this one: