SQL Level 1 Test

Updated · 6 min read
easyPostgreSQL 18sqltestquizassessmentlevel-1

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

Level 1 test: 15 questions

15 questions
1What does SQL stand for?
2In a relational database, one row of students is:
3Which statement reads data?
4SELECT DISTINCT state FROM students; returns:
5Rows come back in a guaranteed order only when the query has:
6Which finds titles starting with Java?
7WHERE fee_usd BETWEEN 200 AND 450 includes a fee of exactly 450?
8Which finds students with no email?
9UPDATE courses SET fee_usd = 0; without a WHERE:
10Which returns one row per technology with its course count?
11Which keeps only groups with more than one course?
12avg(x) over the values 2, 4 and NULL is:
13Which column type stores a date without a time?
14DELETE FROM payments WHERE payment_id = 99; when no such row exists:
15Which CREATE TABLE column definition refuses a missing value?

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
SQL▶ Try it
SELECT title FROM courses WHERE fee_usd > 400 ORDER BY fee_usd DESC, title;
Output
       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
SQL▶ Try it
SELECT title, fee_usd
FROM courses
WHERE fee_usd < 400
ORDER BY fee_usd, title;
Output
   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
SQL▶ Try it
SELECT first_name
FROM students
WHERE email IS NULL
ORDER BY first_name;
Output
 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
SQL▶ Try it
SELECT coalesce(method, 'unknown') AS method, count(*) AS payments
FROM payments
GROUP BY method
ORDER BY payments DESC, method;
Output
 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
SQL▶ Try it
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';
Output
INSERT 0 1
 
 course_id |    title     | fee_usd | prerequisite_id
-----------+--------------+---------+-----------------
         7 | SQL Advanced |  450.00 |               4
(1 row)

What Your Score Means

ScoreWhat to do
18 to 20Excellent. Move on to the SQL Level 2 Test when you reach it.
15 to 17A pass. Reread the lessons linked from the questions you missed.
Below 15Not yet. Revise the linked lessons and take the test again in a day or two.

Was this tutorial helpful?