Bird
0
0

Given the table Inventory with rows:

medium📝 query result Q4 of 15
SQL - Aggregate Functions
Given the table Inventory with rows:
Item | Stock
Pen | 12
Book | 8
Pen | 5

What is the result of:
SELECT SUM(Stock) FROM Inventory WHERE Item = 'Pen';?
A17
B12
C5
DNULL
Step-by-Step Solution
Solution:
  1. Step 1: Identify rows matching condition

    Rows where Item = 'Pen' are 12 and 5.
  2. Step 2: Apply SUM() on filtered rows

    Sum = 12 + 5 = 17.
  3. Final Answer:

    17 -> Option A
  4. Quick Check:

    Sum of Pen stock values is 17 [OK]
Quick Trick: SUM() adds only filtered rows [OK]
Common Mistakes:
MISTAKES
  • Summing all rows ignoring WHERE clause
  • Selecting a single row value instead of sum
  • Confusing SUM() with COUNT()

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More SQL Quizzes