Filter results older than 90 days ("We miss you" feature)

I have a database where users login. I want to see which users haven’t logged in for over 90 days to follow up with them.

I am really close.

This query pulls the last login timestamp for each user:

SELECT MAX(timestamp) as timestamp, user_id FROM user_metrics GROUP BY user_id

Output like this:

bob - 2010-08-11 05:23:38
nancy - 2009-06-30 03:49:28
joe - 2009-08-09 16:50:14

Now, I want to add this WHERE statement to only pull max timestamps that are 90 days or older.

WHERE timestamp < NOW() - INTERVAL 90 DAY

The problem is when I add this WHERE statement, it just pulls any timestamp for that user that is 90 days or older, instead of omitting it from the query.

Output looks like this (“bobs” output is changed to a date later than 90 days instead of being ommitted):

bob - 2010-05-11 05:23:38
nancy - 2009-06-30 03:49:28
joe - 2009-08-09 16:50:14

Ideally I just want it to omit bob and look like this, since these two users have not logged in since over 90 days

nancy - 2009-06-30 03:49:28
joe - 2009-08-09 16:50:14

What am I doing wrong?

perfect thank you swamp!


select max(TIMESTAMP) as TIMESTAMP, 
       user_id 
  from user_metrics 
 group by user_id
having max(TIMESTAMP) < current_date - interval '90' day