SQL Level 1 Test
This test checks Level 1 of the course, Beginner: the beginner lessons: databases, SELECT, filtering, changing data, aggregates and tables. It has two parts. The 15 questions test that you know what each feature does; the 5 hands-on tasks test that you can use it, the way real work does: you run your own SQL in Try it and compare it with the solution. If you pass, you're ready for the next level; if you don't, every question links to the lesson that explains it.
How the Test Works
- Part 1: 15 multiple-choice questions, marked for you.
- Part 2: 5 tasks of these kinds: Predict and Write. Write your query, run it, then open the solution and compare the rows. Any query that returns the same rows passes; the order matters only when the task asks for one.
- Pass mark: 15 out of 20 (questions plus tasks). Give yourself one point per task whose result matches.
- Time: about 45 minutes. No notes for Part 1; Part 2 is open-book, as real work is.
- Covers: the lessons from What Is a Database to CREATE TABLE.
Part 1: 15 Questions
Part 2: 5 Hands-On Tasks
Task 1 (Predict): What does it return?. Before running it, say what this query returns: SELECT title FROM courses WHERE fee_usd > 400 ORDER BY fee_usd DESC, title;
Show solution
SELECT title FROM courses WHERE fee_usd > 400 ORDER BY fee_usd DESC, title; title
-------------------
Java Collections
Java OOP
Java Basics
JavaScript Basics
(4 rows)Task 2 (Write): Courses under $400. List the title and fee of every course costing less than $400, cheapest first.
Show solution
SELECT title, fee_usd
FROM courses
WHERE fee_usd < 400
ORDER BY fee_usd, title; title | fee_usd
------------+---------
Git Basics | 250.00
(1 row)Task 3 (Write): Students without an email. List the first names of students who have no email address, alphabetically.
Show solution
SELECT first_name
FROM students
WHERE email IS NULL
ORDER BY first_name; first_name
------------
Advitha
Navika
(2 rows)Task 4 (Write): Payments by method. Show how many payments were made with each method, including payments with no method, most common first.
Show solution
SELECT coalesce(method, 'unknown') AS method, count(*) AS payments
FROM payments
GROUP BY method
ORDER BY payments DESC, method; method | payments
---------+----------
card | 4
check | 2
unknown | 1
(3 rows)Task 5 (Write): A new course. Add a course "SQL Advanced" (technology SQL, level Intermediate, fee $450.00, prerequisite SQL Basics, course 4), then show it.
Show solution
INSERT INTO courses (title, technology, level, fee_usd, prerequisite_id)
VALUES ('SQL Advanced', 'SQL', 'Intermediate', 450.00, 4);
SELECT course_id, title, fee_usd, prerequisite_id
FROM courses
WHERE title = 'SQL Advanced';INSERT 0 1
course_id | title | fee_usd | prerequisite_id
-----------+--------------+---------+-----------------
7 | SQL Advanced | 450.00 | 4
(1 row)What Your Score Means
| Score | What to do |
|---|---|
| 18 to 20 | Excellent. Move on to the SQL Level 2 Test when you reach it. |
| 15 to 17 | A pass. Reread the lessons linked from the questions you missed. |
| Below 15 | Not yet. Revise the linked lessons and take the test again in a day or two. |
Was this tutorial helpful?