Imagine the following scenario where we have two tables. One table stores our players with their status, creation date and id and another table keeps their login activity.
I want to retrieve all the players which logged in more than N years ago or those who never logged in. As you can see we have a player with id = 4 who never logged into the game so we also want to include him in our list by checking his creation date.
It is also possible to have multiple entries for a player in the Activity Table so our interest is to bring only the row which has a [max(LoginDate) < N] for that player.
I already have a solution but I am eager to see different approaches.
PLAYER_TABLE
--------------------------------------
|PlayerId |CreationDate | Status |
--------------------------------------
|1 |01.01.2000 | ACTIVE |
--------------------------------------
|2 |01.01.2019 | ACTIVE |
--------------------------------------
|3 |01.01.2001 | SUSPENDED|
--------------------------------------
|4 |01.01.2004 | ACTIVE |
--------------------------------------
ACTIVITY_TABLE
-----------------------
|AccountId |LoginDate |
-----------------------
|1 |01.01.2005 |
-----------------------
|1 |05.06.2007 |
-----------------------
|2 |03.05.2010 |
-----------------------
|3 |01.01.2018 |
-----------------------