THE JOB TESTS · SASFLYNET KFT. · FREE PRACTICE GUIDE

SQL Basics Practice: practice, explain, check

Practise SELECT, filtering, grouping and joins with fictional data. Examples use common PostgreSQL-compatible SQL. This is a knowledge practice set, not a coding assessment.

This original 12-question practice set describes only the sampled questions. It is not a validated proficiency level, aptitude percentile, language certificate or hiring recommendation. All examples and data are fictional.

Your seven-day plan

  1. Days 1–2: Selecting and filtering

    Create a fictional orders table in a local practice database. Select specific columns, filter one status and order results by a numeric amount.

  2. Days 3–4: Grouping and counts

    Use three North and South orders. Compare COUNT(*), COUNT(column) and grouped SUM; verify each result against the source rows.

  3. Days 5–6: Joins and missing data

    Create two customers and one matching order. Compare an inner join with a left join and inspect the unmatched customer before adding another order.

  4. Day 7: check independently

    Try one changed example from each topic without the guide. Repeating the same questions can reflect familiarity; use a new example to check transfer.

1. Which query retrieves only name from employees?

My answer and reasoning:

Worked answer

SELECT name FROM employees;

SELECT specifies the requested columns; FROM names the source table.

2. Which clause filters source rows before grouping?

My answer and reasoning:

Worked answer

WHERE

WHERE selects rows that satisfy a condition before aggregation.

3. Which query sorts amount from largest to smallest?

My answer and reasoning:

Worked answer

SELECT amount FROM orders ORDER BY amount DESC;

ORDER BY amount DESC requests descending order. Without ORDER BY, row order is not guaranteed.

4. How should you test a column for a SQL NULL value?

My answer and reasoning:

Worked answer

WHERE note IS NULL

NULL is tested with IS NULL. Equality to NULL does not behave like equality to an ordinary value.

5. Three rows have amount values 10, NULL and 20. What does COUNT(amount) return?

My answer and reasoning:

Worked answer

2

COUNT(expression) counts non-null expression values: 10 and 20.

6. Three rows have amount values 10, NULL and 20. What does COUNT(*) return?

My answer and reasoning:

Worked answer

3

COUNT(*) counts rows, including the row with a null amount.

7. Rows are North 10, South 5, North 20. What North total is produced by grouping region and summing amount?

My answer and reasoning:

Worked answer

30

The North rows contribute 10 + 20 = 30. The South row belongs to a different group.

8. Which clause filters groups by SUM(amount) > 100?

My answer and reasoning:

Worked answer

HAVING SUM(amount) > 100

HAVING applies conditions to grouped results; WHERE applies to source rows.

9. Customers are IDs 1 and 2. The only order belongs to customer 1. Which join preserves customer 2?

My answer and reasoning:

Worked answer

Customers LEFT JOIN orders on matching customer ID

A left join preserves every left-side customer; unmatched right-side columns are null.

10. A customer has three matching orders. An inner join between that customer and orders normally returns how many rows for the customer?

My answer and reasoning:

Worked answer

3

A one-to-many relationship produces one result row per matching pair, here three.

11. What does SELECT DISTINCT region remove?

My answer and reasoning:

Worked answer

Duplicate region values from the result

DISTINCT removes duplicate selected rows in the output. It does not delete source records or guarantee ordering.

12. In a left join, adding WHERE orders.id IS NOT NULL has what effect on unmatched customers?

My answer and reasoning:

Worked answer

It removes them from the result

Unmatched rows have a null right-side order ID. The WHERE condition rejects those rows.

This worksheet sends no entries to us. Print or save it as PDF from your browser. Return to the free test.