0
0
SQLquery~10 mins

WHERE with AND operator 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 all columns from the table employees where the department is 'Sales' and the status is 'Active'.

SQL
SELECT * FROM employees WHERE department = 'Sales' [1] status = 'Active';
Drag options to blanks, or click blank then click option'
ABETWEEN
BAND
CNOT
DOR
Attempts:
3 left
💡 Hint
Common Mistakes
Using OR instead of AND, which would select employees in Sales or Active, not both.
Using NOT which negates a condition.
Using BETWEEN which is for ranges, not combining conditions.
2fill in blank
medium

Complete the code to select name and salary from employees where the salary is greater than 50000 and the department is 'HR'.

SQL
SELECT name, salary FROM employees WHERE salary > 50000 [1] department = 'HR';
Drag options to blanks, or click blank then click option'
AAND
BOR
CLIKE
DIN
Attempts:
3 left
💡 Hint
Common Mistakes
Using OR which would select employees with salary > 50000 or in HR, not necessarily both.
Using LIKE which is for pattern matching.
Using IN which checks if a value is in a list.
3fill in blank
hard

Fix the error in the query to select id from products where price is less than 100 and stock is more than 50.

SQL
SELECT id FROM products WHERE price < 100 [1] stock > 50;
Drag options to blanks, or click blank then click option'
AOR
BNOT
CAND
DXOR
Attempts:
3 left
💡 Hint
Common Mistakes
Using OR which would select products with price < 100 or stock > 50, not both.
Using NOT which negates a condition.
Using XOR which is not standard SQL.
4fill in blank
hard

Fill both blanks to select username and email from users where age is greater than 18 and country is 'USA'.

SQL
SELECT username, email FROM users WHERE age [1] 18 [2] country = 'USA';
Drag options to blanks, or click blank then click option'
A>
B<
CAND
DOR
Attempts:
3 left
💡 Hint
Common Mistakes
Using < instead of > for age.
Using OR instead of AND which would allow either condition to be true.
5fill in blank
hard

Fill all three blanks to select product_name and price from products where category is 'Books', price is less than 20, and stock is more than 10.

SQL
SELECT product_name, price FROM products WHERE category = 'Books' [1] price [2] 20 [3] stock > 10;
Drag options to blanks, or click blank then click option'
AAND
B<
DOR
Attempts:
3 left
💡 Hint
Common Mistakes
Using OR instead of AND which would select products meeting any one condition.
Using > instead of < for price comparison.