Challenge - 5 Problems
View Mastery Badge
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ query_result
intermediate2:00remaining
Output of a simple CREATE VIEW query
Given the table Employees with columns id, name, and department, what will be the result of the following SQL query?
CREATE VIEW SalesEmployees AS SELECT id, name FROM Employees WHERE department = 'Sales';
SELECT * FROM SalesEmployees;SQL
CREATE VIEW SalesEmployees AS SELECT id, name FROM Employees WHERE department = 'Sales'; SELECT * FROM SalesEmployees;
Attempts:
2 left
💡 Hint
Think about what the WHERE clause inside the view does.
✗ Incorrect
The view SalesEmployees selects only id and name from Employees where department is 'Sales'. The SELECT from the view returns those filtered rows.
📝 Syntax
intermediate2:00remaining
Identify the syntax error in CREATE VIEW statement
Which option contains a syntax error in the CREATE VIEW statement?
Attempts:
2 left
💡 Hint
Check the order of keywords in the CREATE VIEW syntax.
✗ Incorrect
The correct syntax is CREATE VIEW view_name AS SELECT ... The option A has 'AS' before the view name, which is invalid syntax.
❓ optimization
advanced2:00remaining
Choosing the best CREATE VIEW for performance
You want to create a view that shows only active customers from the Customers table. Which CREATE VIEW statement is most efficient if the Customers table has millions of rows and an index on the status column?
Attempts:
2 left
💡 Hint
Selecting only needed columns can improve performance.
✗ Incorrect
Option C selects only id and name columns for active customers, reducing data size and using the index on status. Option C selects all columns which may be large. Options C and D do not filter by status.
🔧 Debug
advanced2:00remaining
Why does this CREATE VIEW statement fail?
Consider this SQL statement:
Why might this statement fail in some SQL databases?
CREATE VIEW EmployeeSummary AS SELECT id, name, salary * 1.1 adjusted_salary FROM Employees;Why might this statement fail in some SQL databases?
Attempts:
2 left
💡 Hint
Check the syntax for aliasing columns in SELECT statements inside views.
✗ Incorrect
Some SQL databases require the keyword AS before the alias in the SELECT clause. Omitting AS can cause syntax errors.
🧠 Conceptual
expert2:00remaining
Understanding limitations of CREATE VIEW
Which of the following is NOT a limitation of SQL views created with CREATE VIEW?
Attempts:
2 left
💡 Hint
Think about how views behave like tables in queries.
✗ Incorrect
Views can be used in JOIN operations just like tables. The other options are true limitations: ORDER BY is restricted, indexes cannot be created on views directly, and some databases restrict subqueries in views.