Bird
0
0

Consider the view:

medium📝 query result Q5 of 15
SQL - Views
Consider the view:
CREATE VIEW employee_summary AS SELECT department, COUNT(*) AS emp_count FROM employees GROUP BY department;

What will the query SELECT * FROM employee_summary WHERE emp_count > 5; return?
ADepartments with more than 5 employees
BEmployees with salary greater than 5
CAll employees regardless of department
DDepartments with exactly 5 employees
Step-by-Step Solution
Solution:
  1. Step 1: Understand the view's aggregation

    The view groups employees by department and counts employees per department.
  2. Step 2: Apply the query filter

    The query selects departments where emp_count (number of employees) is greater than 5.
  3. Final Answer:

    Departments with more than 5 employees -> Option A
  4. Quick Check:

    Filter on aggregated count = departments with emp_count > 5 [OK]
Quick Trick: Filters on views apply to the view's result set [OK]
Common Mistakes:
MISTAKES
  • Confusing emp_count with salary
  • Ignoring GROUP BY effect
  • Assuming emp_count is employee ID

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More SQL Quizzes