I have a query. I use an alias in order by when using row_number and I got
 ERROR: column "total_comments" does not exist error
How can I fix this?
select cr_seller_history_id, c.created_at, company_name, business_name, brand, kep_mail, address, phone, mail, slug, name, point, contact_positive, contact_negative, product_number, (product_positive + product_negative) as total_comments, ROW_NUMBER() OVER(ORDER BY total_comments) as rank from cr_companies a INNER JOIN cr_sellers b ON a.cr_company_id = b.cr_company_id INNER JOIN cr_seller_histories c ON b.cr_seller_id = c.cr_seller_id WHERE DATE(c.created_at) = DATE 'yesterday' ORDER BY total_comments DESC NULLS LAST