0
0
SQLquery~10 mins

View as a saved query mental model 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 create a view named 'active_users' that shows users with status 'active'.

SQL
CREATE VIEW active_users AS SELECT * FROM users WHERE status = '[1]';
Drag options to blanks, or click blank then click option'
Apending
Binactive
Cactive
Ddeleted
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'inactive' or other statuses will show wrong users or no users.
2fill in blank
medium

Complete the code to select all columns from the view 'active_users'.

SQL
SELECT [1] FROM active_users;
Drag options to blanks, or click blank then click option'
Aname
B*
Cid
Dstatus
Attempts:
3 left
💡 Hint
Common Mistakes
Selecting only one column when all columns are needed.
3fill in blank
hard

Fix the error in the code to drop the view named 'active_users'.

SQL
DROP [1] active_users;
Drag options to blanks, or click blank then click option'
AVIEW
BTABLE
CDATABASE
DINDEX
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'DROP TABLE' instead of 'DROP VIEW' causes errors.
4fill in blank
hard

Fill both blanks to create a view named 'high_salary' showing employees with salary greater than 50000.

SQL
CREATE [1] high_salary AS SELECT * FROM employees WHERE salary [2] 50000;
Drag options to blanks, or click blank then click option'
AVIEW
BTABLE
C>
D<
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'TABLE' instead of 'VIEW' or wrong comparison operators.
5fill in blank
hard

Fill all three blanks to select employee names and salaries from the 'high_salary' view where salary is less than 70000.

SQL
SELECT [1], [2] FROM high_salary WHERE salary [3] 70000;
Drag options to blanks, or click blank then click option'
Aname
Bsalary
C<
D>
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong columns or wrong comparison operator.