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
- Missing comma after
hire_date—COUNT(reports_to)is parsed as part of the previous select item. - Aggregate mixed with non-aggregated columns —
COUNT(reports_to)cannot be selected alongsideemployee_id,first_nameandhire_datewithout aGROUP BY, or the count must become a correlated subquery. - Dangling
ANDinWHERE— the predicate ends without a right-hand condition.
🧾 Query
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.