Quizz
The full text of this chapter, to read or revisit. To practise, do the exercises.
▶ Do the exercisesExercise 1 — Identify the Correct Filter
Which SQL query will return ONLY Codémons with a power rating above 80?
Hint : Pay attention to the comparison operator. Some operators include the threshold value while others don't.
Exercise 2 — Filter by Type
Complete the query to find all Codémons that are either water or electric type.
Hint : Think about which logical operator should be used when you want to match either one condition OR another condition.
Exercise 3 — Match Queries with Descriptions
Match each SQL query with what it accomplishes. Every query starts with SELECT * FROM codemon.
WHERE power < 75;WHERE type = 'rock';WHERE power BETWEEN 70 AND 80;WHERE type <> 'water' AND type <> 'fire';Exercise 4 — Filtering with NULL
Which query will return all Codémons that have a known type but an unknown level?
Hint : Remember how NULL values must be handled in SQL and which operator should be used to test for NULL or NOT NULL.
Exercise 5 — Complex Filtering
Complete the query to find all fire-type Codémons with a level above 15 OR all plant-type Codémons with a power below 75.
Hint : Think about how to structure compound conditions with AND and OR.
Exercise 6 — Using NOT in Filters
Which query will return all Codémons EXCEPT those with a power of 75?
Hint : Consider the different ways to express negation in SQL and whether they're equivalent in this context.
Exercise 7 — Codémon Query Results
Match each SQL query with the Codémons it will return from the table. Every query starts with SELECT * FROM codemon.
WHERE level IS NULL OR power IS NULL;WHERE type IS NOT NULL AND level IS NOT NULL;WHERE NOT (level IS NULL);WHERE power IS NULL OR type = 'water';Exercise 8 — Power Range Query
Complete the query to find all Codémons with a power between 70 and 80 (inclusive).
Hint : Think about the logical operators needed when using comparison operators. Note: the BETWEEN operator could also be used in a case like this (but not in this exercise, with these specific blanks to fill).
Exercise 9 — Predict the Result
How many Codémons will the following query return?
SELECT * FROM codemon
WHERE level > 15 OR type = 'plant';Hint : Analyze each Codémon in the table and check if it satisfies either of the conditions. Remember that OR means either condition can be true.
Exercise 10 — Complete NULL Filter
Complete the query to find all Codémons that have either a NULL power OR a NULL level, but NOT both.
Hint : This is a complex logical condition. Think about how to express "either A or B, but not both" in SQL.
Exercise 11 — Equivalent Queries
Match each query with its equivalent alternative that would return the same results.
WHERE NOT level <= 15;WHERE level BETWEEN 15 AND 20;WHERE type <> 'fire';WHERE type = 'water' OR type = 'plant';WHERE level > 15;WHERE level >= 15 AND level <= 20;WHERE NOT type = 'fire';WHERE type IN ('water', 'plant');Exercise 12 — Operator Precedence
What does the following query return?
SELECT * FROM codemon
WHERE type = 'water' OR type = 'fire' AND power > 75;Hint : This question tests your understanding of operator precedence in SQL. Remember that AND has higher precedence than OR.
Exercise 13 — Filtering Challenge
Complete the query to find the Codémons whose power is not NULL and greater than 60, and that are NOT water type.
Hint : This is basic AND filtering — just pay attention to the NULL check.
Exercise 14 — Finding Errors
Which query contains a logical error?
Hint : Here's a hint: don't look at the words, try to find a symbol that doesn't belong here.
Exercise 15 — Match Query with Count
Match each query with the number of Codémons it will return. All queries start with SELECT * FROM codemon.
WHERE power >= 75 AND type <> 'fire';WHERE type = 'water' OR type = 'plant';WHERE power > 80;WHERE power BETWEEN 70 AND 80;Exercise 16 — Find Elite Codémons
Complete the query to find all 'elite' Codémons — those with both level above 15 and power above 75.
Hint : Think about which logical operator combines multiple conditions where ALL must be true.
Exercise 17 — Advanced NULL Filtering
Which query correctly finds Codémons that have no NULL values in any column?
Hint : Think brute force.
Exercise 18 — NOT IN Filter
Complete the query to find all Codémons that are neither water nor fire type.
Hint : Think about the SQL operator that lets you check if a value is not in a list of specified values.
Exercise 19 — Operator Precedence Challenge
Which query is equivalent to:
WHERE (type = 'water' OR type = 'fire')
AND level > 15;Hint : This tests your understanding of operator precedence and alternative syntax. Think about which queries would produce the exact same results.
Exercise 20 — NULL Filter Descriptions
Match each query with what it's trying to find. Every query starts with SELECT * FROM codemon WHERE.
type IS NULL;level IS NOT NULL AND power IS NULL;type IS NOT NULL AND level IS NOT NULL AND power IS NOT NULL;level IS NULL OR power IS NULL;Exercise 21 — Find Specific Power Range
Complete the query to find Codémons with power that's either less than 75 or greater than 80.
Hint : This is testing your ability to express a range exclusion. Think about which logical operator to use to combine two conditions when at least one must be true.
Exercise 22 — Complex Filter Analysis
What will the following query return?
SELECT * FROM codemon
WHERE (type = 'water' OR type = 'fire')
AND (level IS NULL OR power > 80);Hint : Analyze the complex condition by breaking it down into parts and evaluating them step by step for each Codémon in the table.
Exercise 23 — Filtering Techniques
Match each filtering technique with its SQL implementation.
level BETWEEN 15 AND 20type IN ('water', 'fire')NOT type = 'fire'type <> 'plant'Exercise 24 — Advanced Filtering Challenge
Complete the query to find all plant-type Codémons OR Codémons with level greater than 20, but NOT those with power less than 75.
Hint : This tests your ability to construct complex filters with multiple conditions and proper use of parentheses for operator precedence.
Exercise 25 — Finding Missing Data
You need to find Codémons with at least two NULL values. Which query is correct?
Hint : Sometimes the easiest way is the one that looks almost too dumb.
Exercise 26 — Starting letter
Which condition finds the names that start with the letter A?
name LIKE 'A%'name LIKE '%A'name = 'A%'name LIKE 'A_'Hint : With LIKE, the % goes where "anything" is allowed — here, after the A.
Exercise 27 — Ends with chu
Complete the query to find the Codémons whose name ends with "chu".
Hint : Which operator accepts a pattern instead of an exact value?
Exercise 28 — Wildcards
Match each element with its meaning.
%_LIKE 'Py%'NOT LIKE '%a%'