SQL validator
SELECT employee_id, first_name || ' ' || last_name AS full_name, hire_date COUNT(reports_to) FROM employees WHERE salary > 50000 AND ORDER BY full_name;
●Reviewing your schemadone350ms

❌ Query is invalid!

🔍 Findings

  1. Missing comma after hire_date — COUNT(reports_to) is parsed as part of the previous select item.
  2. Aggregate mixed with non-aggregated columns — COUNT(reports_to) cannot be selected alongside employee_id, first_name and hire_date without a GROUP BY, or the count must become a correlated subquery.
  3. Dangling AND in WHERE — the predicate ends without a right-hand condition.

🧾 Query

sql
SELECT
  e.employee_id,
  e.first_name || ' ' || e.last_name AS full_name,
  e.hire_date,
  (SELECT COUNT(*) FROM employees AS r WHERE r.reports_to = e.employee_id) AS reports_count
FROM employees AS e
WHERE e.salary > 50000
ORDER BY full_name;

12s

Example conversation

Sign in to run this generator on your own schema.

Sign in to try it