Query with a CTE
WITH current_staff AS ( SELECT * FROM person WHERE active AND ( leaving_date IS NULL OR leaving_date >= CURRENT_DATE ) AND (start_date <= CURRENT_DATE) ) SELECT count(*) FROM current_staff;
WITH current_staff AS ( SELECT * FROM person WHERE active AND ( leaving_date IS NULL OR leaving_date >= CURRENT_DATE ) AND (start_date <= CURRENT_DATE) ) SELECT count(*) FROM current_staff;