Finding count of objects within a specified time window in SQL (Postgresql DB)
Use conditional aggregation:

select count(*) filter (where date_joined &gt; now() - interval'24 hours') as last_24_hours,
       count(*) filter (where date_joined &gt; now() - interval'48 hours') as last_48_hours
from auth_user


The filter clause is available since Postgres 9.4, for older versions you need to use a case statement:

select count(case when date_joined &gt; now() - interval'24 hours' then 1 end) as last_24_hours,
       count(case when date_joined &gt; now() - interval'48 hours' then 1 end) as last_48_hours
from auth_user