I like using HAVING just to have conditions that reference expressions from the SELECT columns.
e.g. rather than having to do
SELECT
COALESCE(extract_district(rm.district), extract_district(p.project_name), NULLIF(rm.district, '')) AS district,
...
FROM ...
WHERE COALESCE(extract_district(rm.district), extract_district(p.project_name), NULLIF(rm.district, '')) IS NOT NULL
just do
SELECT
COALESCE(extract_district(rm.district), extract_district(p.project_name), NULLIF(rm.district, '')) AS district,
...
FROM ...
HAVING district IS NOT NULL
Hopefully the optimizer understands that these are equivalent, I haven't checked.
e.g. rather than having to do
just do Hopefully the optimizer understands that these are equivalent, I haven't checked.