0
0
SQLquery~10 mins

Operator precedence in WHERE 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 age is greater than 30 and city is 'New York'.

SQL
SELECT * FROM users WHERE age [1] 30 AND city = 'New York';
Drag options to blanks, or click blank then click option'
A<
B<=
C>
D=
Attempts:
3 left
💡 Hint
Common Mistakes
Using '=' instead of '>' which selects only age exactly 30.
Using '<' which selects ages less than 30.
2fill in blank
medium

Complete the code to select rows where status is 'active' or last_login is before 2023-01-01.

SQL
SELECT * FROM accounts WHERE status = 'active' OR last_login [1] '2023-01-01';
Drag options to blanks, or click blank then click option'
A>=
B!=
C=
D<
Attempts:
3 left
💡 Hint
Common Mistakes
Using '>=' which selects dates after or on 2023-01-01.
Using '=' which selects only logins exactly on 2023-01-01.
3fill in blank
hard

Fix the error in the WHERE clause to correctly select rows where score is greater than 80 and grade is 'A' or 'B'.

SQL
SELECT * FROM results WHERE score [1] 80 AND (grade = 'A' OR grade = 'B');
Drag options to blanks, or click blank then click option'
A>
B<
C=
D<=
Attempts:
3 left
💡 Hint
Common Mistakes
Using '<' which selects scores less than 80.
Using '=' which selects scores exactly 80.
4fill in blank
hard

Fill both blanks to select rows where salary is greater than 50000 and department is 'Sales' or 'Marketing'.

SQL
SELECT * FROM employees WHERE salary [1] 50000 AND (department [2] 'Sales' OR department = 'Marketing');
Drag options to blanks, or click blank then click option'
A>
B<
C=
D!=
Attempts:
3 left
💡 Hint
Common Mistakes
Using '<' for salary which selects lower salaries.
Using '!=' for department which excludes 'Sales'.
5fill in blank
hard

Fill all three blanks to select rows where age is less than 40, city is 'Chicago', and status is not 'inactive'.

SQL
SELECT * FROM users WHERE age [1] 40 AND city [2] 'Chicago' AND status [3] 'inactive';
Drag options to blanks, or click blank then click option'
A>
B<
C=
D!=
Attempts:
3 left
💡 Hint
Common Mistakes
Using '>' for age which selects older people.
Using '=' for status which selects only 'inactive'.