Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete 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'
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.
✗ Incorrect
The AND operator is used to combine two conditions that both must be true. Here, we want employees in the Sales department who are also Active.
2fill in blank
mediumComplete 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'
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.
✗ Incorrect
AND is used to ensure both conditions are true: salary greater than 50000 and department equals HR.
3fill in blank
hardFix 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'
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.
✗ Incorrect
AND is needed to combine the two conditions so both must be true: price less than 100 and stock more than 50.
4fill in blank
hardFill 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'
Attempts:
3 left
💡 Hint
Common Mistakes
Using < instead of > for age.
Using OR instead of AND which would allow either condition to be true.
✗ Incorrect
The age must be greater than 18, so > is correct. The conditions are combined with AND to require both to be true.
5fill in blank
hardFill 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'
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.
✗ Incorrect
The conditions are combined with AND operators. The price comparison uses < to check less than 20.