Bird
0
0

Given the view:

medium📝 Debug Q7 of 15
SQL - Views
Given the view:
CREATE VIEW sales_summary AS SELECT region, SUM(amount) AS total_sales FROM sales GROUP BY region;

Which query will cause an error?
ASELECT region, total_sales FROM sales_summary WHERE total_sales > 1000;
BSELECT * FROM sales_summary;
CSELECT region FROM sales_summary WHERE total_sales < 500;
DINSERT INTO sales_summary (region, total_sales) VALUES ('East', 5000);
Step-by-Step Solution
Solution:
  1. Step 1: Understand that views with GROUP BY are not updatable

    Views that aggregate data cannot be inserted into directly.
  2. Step 2: Identify the query that tries to insert data

    INSERT INTO sales_summary (region, total_sales) VALUES ('East', 5000); tries to INSERT into the view, which will cause an error.
  3. Final Answer:

    INSERT INTO sales_summary (region, total_sales) VALUES ('East', 5000); -> Option D
  4. Quick Check:

    Inserting into aggregated view causes error [OK]
Quick Trick: Aggregated views cannot be inserted into [OK]
Common Mistakes:
MISTAKES
  • Trying to insert into aggregated views
  • Confusing SELECT with INSERT
  • Assuming all views are updatable

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More SQL Quizzes