Already know some SQL? Answer these 15 questions, about 8 minutes. Each topic you get fully right is marked Known on the SQL roadmap , so you can skip it. Each one you miss is listed for you to study.
Don’t guess. Pick “I don’t know yet” when you’re not sure: a lucky guess would mark a topic Known that you still need to learn.
The 10 topics it checks Tables, rows and keys SELECT, WHERE, ORDER BY and LIMIT DISTINCT Aggregates GROUP BY and HAVING NULL and three-valued logic Joins: inner, left, right, full, self and cross Simple subqueries INSERT, UPDATE and DELETE Data types and constraints Question 1 of 15 · Predict the output orders.customer_id has REFERENCES customers. There is no customer 99. What happens? INSERT INTO orders (order_id, customer_id, order_date, status, total)
VALUES (115, 99, '2026-10-21', 'placed', 10.00);
The order goes in, with customer_id 99. The order goes in, with customer_id NULL. A customer 99 is made for it. It stops with an error. I don’t know yet
Question 2 of 15 · Predict the output The store has 3 electronics products and 2 home ones. Of these 5, only the headphones (59.00) and the desk lamp (24.99) cost more than 20. How many rows? SELECT name
FROM products
WHERE category = 'electronics' OR category = 'home' AND price > 20;
2 4 5 1 I don’t know yet
Question 3 of 15 · Predict the output orders has 14 rows, from 7 customers, with 4 different statuses. How many rows? SELECT DISTINCT customer_id, status
FROM orders;
7 4 12 14 I don’t know yet
Question 4 of 15 · Predict the output Ben (customer 2) has 4 orders, two of them on 14 October. No one else has more than 3 orders. Which customers does this list? SELECT customer_id
FROM orders
GROUP BY customer_id
HAVING count(DISTINCT order_date) >= 4;
Ben Ben and Asha It stops with an error No one I don’t know yet
Question 5 of 15 · Spot the bug This should list the customers with 2 or more orders. What happens? SELECT customer_id, count(*)
FROM orders
WHERE count(*) >= 2
GROUP BY customer_id;
It stops with an error. It works, and lists 4 customers. It counts every order as one group. It gives no rows. I don’t know yet
Question 6 of 15 · Predict the output Of the 10 employees, Jon and Zoe have manager 7, and Meera has no manager (NULL). How many rows? SELECT name
FROM employees
WHERE manager_id <> 7;
8 10 7 9 I don’t know yet
Question 7 of 15 · Predict the output events has 20 rows: 19 from the store’s customers, and a page view from a visitor who wasn’t signed in (customer_id is NULL). Of the 8 customers, only Chen has no events. How many rows? SELECT c.name, e.event_id
FROM customers c
FULL JOIN events e ON e.customer_id = c.customer_id;
21 20 19 28 I don’t know yet
Question 8 of 15 · Spot the bug This should count each customer’s orders. What does it give Dana, who has none? SELECT c.name, count(*) AS orders
FROM customers c
LEFT JOIN orders o ON o.customer_id = c.customer_id
GROUP BY c.customer_id, c.name;
0 NULL Dana isn’t listed 1 I don’t know yet
Question 9 of 15 · Predict the output Of the store’s 14 orders, only Ben’s 109 and 110 share a customer and a day. How many rows does this self join give? SELECT a.order_id, b.order_id
FROM orders a
JOIN orders b
ON b.customer_id = a.customer_id
AND b.order_date = a.order_date
AND b.order_id <> a.order_id;
1 2 14 16 I don’t know yet
Question 10 of 15 · Predict the output Ben (customer 2) has 4 orders. How many times is he listed? SELECT name
FROM customers
WHERE customer_id IN (SELECT customer_id FROM orders);
Once 4 times Not at all It stops with an error I don’t know yet
Question 11 of 15 · Spot the bug This should list the 6 employees who manage no one. Meera’s manager_id is NULL. How many rows does it give? SELECT name
FROM employees
WHERE employee_id NOT IN (SELECT manager_id FROM employees);
6 10 0 4 I don’t know yet
Question 12 of 15 · Predict the output payments has 13 rows. What does the last line give? BEGIN;
DELETE FROM payments WHERE payment_id = 13;
ROLLBACK;
SELECT count(*) FROM payments;
12 13 0 It stops with an error I don’t know yet
Question 13 of 15 · Predict the output Product 9, the phone stand, is already in products at 6.90. What is its price after this? INSERT INTO products (product_id, name, category, price)
VALUES (9, 'Phone stand', 'electronics', 7.50)
ON CONFLICT (product_id) DO UPDATE SET price = EXCLUDED.price;
6.90 It stops with an error 7.50 There are two rows: 6.90 and 7.50 I don’t know yet
Question 14 of 15 · Multiple choice Which column type keeps a gift card balance exact to the cent? float real double precision numeric(10, 2) I don’t know yet
Question 15 of 15 · Multiple choice A reviews table has stars integer NOT NULL CHECK (stars BETWEEN 1 AND 5). Which value of stars goes in? 'five' 3 0 NULL I don’t know yet
See my results Answered 0 of 15.