0
0
SQLquery~10 mins

NULL in AND, OR, NOT logic in SQL - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to select rows where the condition is TRUE or UNKNOWN using OR.

SQL
SELECT * FROM employees WHERE active = TRUE [1] salary > 50000;
Drag options to blanks, or click blank then click option'
ANOT
B=
COR
DAND
Attempts:
3 left
💡 Hint
Common Mistakes
Using AND instead of OR causes rows with NULL to be excluded.
Using = instead of logical operators.
2fill in blank
medium

Complete the code to find rows where NOT condition is TRUE.

SQL
SELECT * FROM orders WHERE NOT (shipped_date IS NULL) [1] status = 'pending';
Drag options to blanks, or click blank then click option'
ANOT
B=
COR
DAND
Attempts:
3 left
💡 Hint
Common Mistakes
Using OR causes rows to be included even if NOT condition is FALSE.
Using NOT again causes double negation.
3fill in blank
hard

Fix the error in the WHERE clause to correctly handle NULL with AND.

SQL
SELECT * FROM products WHERE price > 100 [1] discount IS NULL;
Drag options to blanks, or click blank then click option'
AAND
BOR
CNOT
D=
Attempts:
3 left
💡 Hint
Common Mistakes
Using OR includes rows where price > 100 but discount is not NULL.
Using = causes syntax error with IS NULL.
4fill in blank
hard

Fill both blanks to select rows where either condition is TRUE or the other is NOT TRUE.

SQL
SELECT * FROM sales WHERE region = 'East' [1] amount > 1000 [2] NOT (discount IS NULL);
Drag options to blanks, or click blank then click option'
AOR
BAND
CAND NOT
DNOT
Attempts:
3 left
💡 Hint
Common Mistakes
Using AND in first blank excludes rows unnecessarily.
Using NOT alone causes syntax errors.
5fill in blank
hard

Fill all three blanks to create a condition that excludes NULLs and selects rows with amount > 500 or status 'active'.

SQL
SELECT * FROM transactions WHERE amount IS NOT [1] AND (amount [2] 500 [3] status = 'active');
Drag options to blanks, or click blank then click option'
ANULL
B>
COR
D=
Attempts:
3 left
💡 Hint
Common Mistakes
Using = NULL instead of IS NOT NULL.
Using AND instead of OR in the last blank.