Bird
0
0

Given the table Sales with columns product, region, and amount, and the view:

medium📝 query result Q13 of 15
SQL - Views
Given the table Sales with columns product, region, and amount, and the view:
CREATE VIEW RegionalSales AS SELECT region, SUM(amount) AS total FROM Sales GROUP BY region;
What will the query SELECT * FROM RegionalSales WHERE total > 1000; return?
AAll rows from Sales table without filtering
BRows showing regions where total sales amount is more than 1000
CSyntax error because views cannot use GROUP BY
DEmpty result because total is not a column in Sales
Step-by-Step Solution
Solution:
  1. Step 1: Understand the view definition

    The view groups sales by region and sums amounts, creating a total per region.
  2. Step 2: Analyze the query on the view

    The query filters regions where total sales exceed 1000, so it returns those regions and totals.
  3. Final Answer:

    Rows showing regions where total sales amount is more than 1000 -> Option B
  4. Quick Check:

    View groups and filters totals > 1000 = A [OK]
Quick Trick: Views can use GROUP BY and filters on aggregated columns [OK]
Common Mistakes:
MISTAKES
  • Thinking views cannot use GROUP BY
  • Confusing view columns with base table columns
  • Assuming syntax error due to alias

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More SQL Quizzes