Bird
0
0

If a view is created as CREATE VIEW SalesSummary AS SELECT region, SUM(amount) AS total FROM Sales GROUP BY region;, what will SELECT * FROM SalesSummary; show?

medium📝 query result Q5 of 15
SQL - Views
If a view is created as CREATE VIEW SalesSummary AS SELECT region, SUM(amount) AS total FROM Sales GROUP BY region;, what will SELECT * FROM SalesSummary; show?
ASum of sales amounts grouped by region
BIndividual sales records without grouping
COnly the regions without any sales data
DAn error because aggregate functions cannot be used in views
Step-by-Step Solution
Solution:
  1. Step 1: Understand the view's query

    The view groups sales by region and calculates the sum of amounts per region.
  2. Step 2: Predict the output of selecting from the view

    Selecting all from the view returns each region with its total sales amount.
  3. Final Answer:

    Sum of sales amounts grouped by region -> Option A
  4. Quick Check:

    Views can include aggregates and grouping [OK]
Quick Trick: Views can summarize data using GROUP BY and aggregates [OK]
Common Mistakes:
MISTAKES
  • Thinking views cannot use aggregate functions
  • Expecting detailed individual records
  • Assuming error due to aggregation

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More SQL Quizzes