I want to make an SQL request to display a list of users but only the one who haven't accepted a mission since at least 60 days. A user have multiple user missions attached to him, so I need to look at all of them and display the user only if no missions have been accepted since 60 days.
Here is what I have so far, but it is wrong, the user is in the list even if he have accepted a mission less than 60 days ago, but the mission doesn't show up though. So this request just display every missions that have been accepted more than 60 days ago. That is not what I want.
SELECT
u.username, u.id, u.email, date_part('days', now() - um.date_accepted) as "days since last mission"
FROM
users_user u
INNER JOIN
users_usermission um
ON
u.id=um.user_id
WHERE
date_part('days', now() - um.date_accepted) > 60
Anyone know how could I fix this request?
Aucun commentaire:
Enregistrer un commentaire