Bird
0
0

You have two views: ViewA shows all customers from region 'East', and ViewB shows customers with orders over $1000. How can you create a new view ViewC that shows customers satisfying both conditions?

hard📝 Application Q9 of 15
SQL - Views
You have two views: ViewA shows all customers from region 'East', and ViewB shows customers with orders over $1000. How can you create a new view ViewC that shows customers satisfying both conditions?
ACREATE VIEW ViewC AS SELECT * FROM ViewA UNION SELECT * FROM ViewB;
BCREATE VIEW ViewC AS SELECT * FROM ViewA INTERSECT SELECT * FROM ViewB;
CCREATE VIEW ViewC AS SELECT * FROM ViewA WHERE orders > 1000;
DCREATE VIEW ViewC AS SELECT * FROM Customers WHERE region = 'East' OR orders > 1000;
Step-by-Step Solution
Solution:
  1. Step 1: Understand the requirement

    ViewC should include customers in both ViewA and ViewB, meaning intersection of the two sets.
  2. Step 2: Choose correct SQL set operation

    INTERSECT returns rows common to both queries, matching the requirement.
  3. Final Answer:

    CREATE VIEW ViewC AS SELECT * FROM ViewA INTERSECT SELECT * FROM ViewB; -> Option B
  4. Quick Check:

    Use INTERSECT to get common rows from two views [OK]
Quick Trick: Use INTERSECT to combine views with AND condition [OK]
Common Mistakes:
MISTAKES
  • Using UNION which combines all rows (OR condition)
  • Using WHERE on views without proper columns
  • Using OR instead of AND logic

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More SQL Quizzes