Seaquel
PostgreSQL error code

PostgreSQL error 42803

42803 is the SQLSTATE PostgreSQL reports for grouping error, in class 42, Syntax Error or Access Rule Violation.

SQLSTATE42803
Condition namegrouping_error
Class42 — Syntax Error or Access Rule Violation

Reproduce it, then fix it

These are the queries from the guide below. Run the broken query to see the error, then switch to the fixed one. Edit either freely; every run is rolled back.

SELECT AVG(COUNT(*)) AS avg_products_per_category
FROM demo.products
GROUP BY category;
SELECT AVG(product_count) AS avg_products_per_category
FROM (
  SELECT category, COUNT(*) AS product_count
  FROM demo.products
  GROUP BY category
) per_category;

How to fix it

In other databases

Source: PostgreSQL documentation, Appendix A