Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to create a simple view named employee_view that selects all columns from the employees table.
MySQL
CREATE VIEW employee_view AS SELECT * FROM [1]; Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using the view name instead of the table name.
Using a singular form of the table name.
✗ Incorrect
The view should select from the existing table named 'employees'.
2fill in blank
mediumComplete the code to create a view named active_customers that selects all columns from customers where the status is 'active'.
MySQL
CREATE VIEW active_customers AS SELECT * FROM customers WHERE status = '[1]';
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'inactive' or other statuses instead of 'active'.
Forgetting to put the status value in quotes.
✗ Incorrect
The view filters customers whose status is 'active'.
3fill in blank
hardFix the error in the code to create a view named order_summary that shows order_id and total_amount from the orders table.
MySQL
CREATE VIEW order_summary AS SELECT order_id, [1] FROM orders; Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using camelCase or missing underscores in column names.
Using hyphens which are invalid in column names.
✗ Incorrect
The correct column name is 'total_amount' with an underscore.
4fill in blank
hardFill both blanks to create a view named high_salary_employees that selects name and salary from employees where salary is greater than 50000.
MySQL
CREATE VIEW high_salary_employees AS SELECT [1], [2] FROM employees WHERE salary > 50000;
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Selecting columns not related to salary or name.
Forgetting to include both required columns.
✗ Incorrect
The view should select 'name' and 'salary' columns.
5fill in blank
hardFill all three blanks to create a view named customer_orders that selects customer_id, order_id, and order_date from the orders table where order_date is after '2023-01-01'.
MySQL
CREATE VIEW customer_orders AS SELECT [1], [2], [3] FROM orders WHERE order_date > '2023-01-01';
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Missing one or more required columns.
Including columns not specified in the instruction.
✗ Incorrect
The view selects 'customer_id', 'order_id', and 'order_date' columns.