Bird
0
0

What will be the result of this query on a star schema?

medium📝 Predict Output Q5 of 15
SQL - Database Design and Normalization
What will be the result of this query on a star schema?
SELECT d.StoreName, COUNT(*) AS SalesCount FROM Sales f INNER JOIN Store d ON f.StoreID = d.StoreID GROUP BY d.StoreName HAVING COUNT(*) > 100;
AAll stores with their total sales amount
BList of sales records without grouping
CStores with less than 100 sales records
DStores with more than 100 sales records and their sales count
Step-by-Step Solution
Solution:
  1. Step 1: Understand JOIN and GROUP BY

    The query joins Sales and Store tables, grouping by store name.
  2. Step 2: Interpret HAVING clause

    HAVING filters groups with sales count greater than 100.
  3. Final Answer:

    Stores with more than 100 sales records and their sales count -> Option D
  4. Quick Check:

    HAVING filters grouped results > 100 [OK]
Quick Trick: Use HAVING to filter groups after aggregation [OK]
Common Mistakes:
  • Confusing HAVING with WHERE
  • Assuming COUNT(*) counts distinct stores
  • Ignoring the grouping effect

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More SQL Quizzes