In the query below, the parameter date_part('year', CURRENT_DATE) - f.birth_year
is repeated three times. How can I replace it by its alias age
?
SELECT
date_part('year', CURRENT_DATE) - f.birth_year AS age
FROM
public.foo f
WHERE
date_part('year', CURRENT_DATE) - f.birth_year >=20 AND
date_part('year', CURRENT_DATE) - f.birth_year <=30