0
0
SQLquery~10 mins

CREATE VIEW syntax 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 selects all columns from the 'users' table.

SQL
CREATE VIEW active_users AS SELECT * FROM [1];
Drag options to blanks, or click blank then click option'
Ausers
Bproducts
Corders
Dcustomers
Attempts:
3 left
💡 Hint
Common Mistakes
Choosing a table unrelated to users like 'orders' or 'products'.
Forgetting to specify the table name after FROM.
2fill in blank
medium

Complete the code to create a view named 'high_salary_employees' that selects employees with salary greater than 50000.

SQL
CREATE VIEW high_salary_employees AS SELECT * FROM employees WHERE salary [1] 50000;
Drag options to blanks, or click blank then click option'
A<=
B<
C=
D>
Attempts:
3 left
💡 Hint
Common Mistakes
Using < or <= which select lower salaries.
Using = which selects only salaries exactly 50000.
3fill in blank
hard

Fix the error in the code to create a view named 'customer_emails' that selects only the email column from customers.

SQL
CREATE VIEW customer_emails AS SELECT [1] FROM customers;
Drag options to blanks, or click blank then click option'
Aemail
B*
Cemails
Dcustomer_email
Attempts:
3 left
💡 Hint
Common Mistakes
Using '*' which selects all columns instead of just email.
Using incorrect column names like 'emails' or 'customer_email'.
4fill in blank
hard

Fill both blanks to create a view named 'recent_orders' that selects order_id and order_date from orders placed after 2023-01-01.

SQL
CREATE VIEW recent_orders AS SELECT [1], [2] FROM orders WHERE order_date > '2023-01-01';
Drag options to blanks, or click blank then click option'
Aorder_id
Border_date
Ccustomer_id
Dtotal_amount
Attempts:
3 left
💡 Hint
Common Mistakes
Selecting unrelated columns like 'customer_id' or 'total_amount'.
Forgetting to select both required columns.
5fill in blank
hard

Fill all three blanks to create a view named 'top_products' that selects product_name and price from products where price is greater than 100.

SQL
CREATE VIEW top_products AS SELECT [1], [2] FROM products WHERE [3] > 100;
Drag options to blanks, or click blank then click option'
Aproduct_name
Bprice
Dproduct_id
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'product_id' instead of 'product_name' or 'price'.
Filtering on a wrong column instead of 'price'.