Bird
0
0

Given a view active_customers defined as SELECT id, name FROM customers WHERE active = true, what will the query SELECT * FROM active_customers WHERE name LIKE 'A%'; return?

medium📝 query result Q4 of 15
PostgreSQL - Views and Materialized Views
Given a view active_customers defined as SELECT id, name FROM customers WHERE active = true, what will the query SELECT * FROM active_customers WHERE name LIKE 'A%'; return?
AAn error because views cannot be filtered
BAll customers regardless of active status
COnly customers with names starting with 'A' ignoring active status
DAll active customers whose names start with 'A'
Step-by-Step Solution
Solution:
  1. Step 1: Understand the view definition

    The view filters customers to only those with active = true.
  2. Step 2: Apply the additional filter on the view

    The query further filters active customers to those whose names start with 'A'.
  3. Final Answer:

    All active customers whose names start with 'A' -> Option D
  4. Quick Check:

    View filters + query filters = A [OK]
Quick Trick: Views can be filtered further in queries [OK]
Common Mistakes:
  • Ignoring the view's WHERE clause
  • Thinking views cannot be filtered
  • Assuming all customers are returned

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PostgreSQL Quizzes