Check if user did not input details in last 3 day

Hi,
I have some problem. I have table with 3 fields: USER_ID, EXERCISE_MINUTES and PROGRESS_DATE

for example we have rows like this:
|USER_ID|EXERCISE_MINUTES|PROGRESS_DATE|
3 10 2010-09-05
9 0 2010-09-11
9 8 2010-09-12
9 20 2010-09-13
2 10 2010-09-10
2 15 2010-09-11
2 12 2010-09-12
2 12 2010-09-13
5 10 2010-09-09
5 0 2010-09-11
5 0 2010-09-12
5 0 2010-09-13

From this rows I should select USER_ID where USER have EXERCISE_MINUTES = 0 in last three days or where user did not enter exercise for more than 3 days. I.e. I should get users with USER_ID:
3 and 5… how to create query like this?

Any help is appreciated
Thanks

Argh, beaten to it!

Does this do it?

SELECT user_id
     , SUM(exercise_minutes) AS total_minutes
  FROM users
 WHERE progress_date >= CURRENT_DATE - INTERVAL '3' DAY
GROUP
    BY user_id
HAVING total_minutes = 0
SELECT user_id
  FROM daTable
 WHERE progress_date >= CURRENT_DATE - 3 DAY
GROUP
    BY user_id
HAVING SUM(exercise_minutes) = 0

unfortunately, this will not return user 4, who did not enter any rows at all

:smiley:

yeah, but my query contains an error :frowning:

Thank you both :slight_smile: