CodeRang
Where to start

SQL test online for practical skill assessment

An SQL test is more useful when you have to write the query yourself instead of choosing an answer from a multiple-choice quiz. Practical tasks can assess joins, aggregation, filtering, and other core SQL skills.

Updated · SQL Arena team

What you will practice

  • Writing SQL without hints
  • Solving tasks under a timer
  • Passing checks on hidden data
  • Reviewing mistakes after a session
  • Confirming a skill level with a certificate

A practice problem in the trainer

This is how a problem looks in SQL Arena: the task, the editor, the result and the database schema.

PrevNextRandom
TaskSubmissionsAI Mentor
Find departments with at least two employees

You have department and employee tables. For every department with at least two employees, return the department name as department_name, the number of employees as employee_count, and the average salary as avg_salary. Sort by average salary from highest to lowest, then by department name.

Query 1PostgreSQLv16
SELECT d.department_name,
       COUNT(e.id) AS employee_count,
       ROUND(AVG(e.salary)) AS avg_salary
FROM departments d
JOIN employees e ON e.department_id = d.id
GROUP BY d.id, d.department_name
HAVING COUNT(e.id) >= 2
ORDER BY avg_salary DESC, d.department_name;
Submit
Resultdepartmentsemployees
Answer accepted

SQL test question: worked solution

Start by identifying where each required value comes from. The department name is stored in departments, while employee records and salaries are stored in employees. The second table references the first through employees.department_id, so the query joins the two tables before calculating anything. In a timed SQL skills assessment, recognizing the relationship quickly is part of the work.

The joined rows are then grouped by department. COUNT(e.id) gives the number of employees in each group, while AVG(e.salary) calculates their average salary. ROUND keeps the displayed average simple. Because the condition applies to an aggregate value after grouping, COUNT(e.id) >= 2 belongs in HAVING rather than WHERE.

Finally, the query defines a deterministic order. Average salary is the primary sort key and department_name is the secondary key. Adding that second expression prevents ties from appearing in an arbitrary order. It is a small detail, but practical SQL exams often reveal whether you think about the complete result rather than stopping as soon as the rows look correct.

An SQL test can assess both syntax knowledge and your ability to reason about data. In a practical SQL exam, a query may be syntactically valid and still be wrong because it joins too many rows, groups at the wrong level, or filters data at the wrong stage. Timed exercises are useful for checking whether you can identify the required tables and build a correct query efficiently. If you want to learn SQL with a certificate, review the exam scope and certification requirements before taking it.

SQLPostgreSQL v16
SELECT d.department_name,
       COUNT(e.id) AS employee_count,
       ROUND(AVG(e.salary)) AS avg_salary
FROM departments d
JOIN employees e ON e.department_id = d.id
GROUP BY d.id, d.department_name
HAVING COUNT(e.id) >= 2
ORDER BY avg_salary DESC, d.department_name;
Query result
department_nameemployee_countavg_salary
Platform287000
Analytics270000
Design260000
Support249500

Common mistakes in SQL tests and exams

01

Putting the aggregate condition in WHERE

WHERE filters source rows before GROUP BY. It cannot directly filter the COUNT produced for each completed group. The employee-count condition belongs in HAVING.

02

Grouping only by the visible department name

Names are labels, not guaranteed identifiers. Grouping by both d.id and d.department_name preserves separate department records even if two rows happen to share the same displayed name.

03

Leaving ties unordered

Sorting only by avg_salary does not define which department comes first when averages are equal. A second ORDER BY expression makes the result deterministic and easier to verify.

Frequently asked questions

What does an SQL test assess?

An SQL test may assess filtering, sorting, joins, aggregation, GROUP BY, subqueries, and window functions. Practical tests also check whether your query returns the correct rows rather than merely using valid syntax.

How can I prepare for an SQL test?

Review the main SQL concepts and solve query-writing tasks without hints. Timed practice can help you identify schemas faster and become more consistent when combining multiple SQL concepts.

What is the difference between an SQL test and an SQL quiz?

A quiz often asks you to choose an answer, while a practical SQL test asks you to write the query yourself. Query-writing tests usually provide a better view of how well you can apply SQL.

How do I prepare for a timed SQL exam?

Practice reading table schemas quickly and solving tasks under a fixed time limit. Check your result for duplicate rows, incorrect joins, wrong aggregation levels, and edge cases before submitting.

How can I learn SQL with a certificate?

Choose a course or exam that includes a certificate and review what must be completed to earn it. A certificate documents completion or assessment under that provider's rules, so its requirements can vary.

Take an SQL test and assess your skills

When practice sessions are no longer enough, move to the certification exam. You solve real SQL tasks under a timer and receive a verifiable certificate for the level you complete.

Go to certification exam