Filtering the first entry within a date range SQL

Struggling to filter from an alias I created. Sorry I'm new to SQL so this could just be a simple SQL thing.

I'm trying to find out the users that have made their first post within past 2 days using:

select user_id,
min(posted_at) as first_post
from timeline_posts
where first_post > '2022/02/15'

I'm getting an error for first_post does not exist. When I change the WHERE to use min(posted_at) I get an error that I can't use functions in a where filter.

Please help

Hi @brianchi
That depends on your database type, but try:
where min(posted_at) > '2022/02/15'

I get an error:
aggregate functions are not allowed in WHERE

@brianchi Okay, try searching in a forum dedicated to your database type or stackoverflow.com

1 Like