Tags / having
It seems like you have accidentally included a large amount of unrelated text in your query.
Understanding HAVING and Aliases in PostgreSQL for Efficient Query Writing
Implementing Keyset Pagination with WHERE and HAVING Clauses for Efficient Database Queries
How to Remove Matching Rows Between Aggregated and Non-Aggregated Columns Using CTEs