Bird
0
0

What will be the output of this query on table products with quantity values (5, 10, 15): SELECT COUNT(quantity), SUM(quantity), MIN(quantity), MAX(quantity) FROM products;?

medium📝 query result Q5 of 15
PostgreSQL - Aggregate Functions and GROUP BY
What will be the output of this query on table products with quantity values (5, 10, 15): SELECT COUNT(quantity), SUM(quantity), MIN(quantity), MAX(quantity) FROM products;?
A3, 30, 5, 15
B3, 30, 15, 5
CNULL, NULL, NULL, NULL
D5, 30, 3, 15
Step-by-Step Solution
Solution:
  1. Step 1: Calculate each aggregate

    COUNT(quantity) = 3 (all values present), SUM(quantity) = 5+10+15=30, MIN(quantity) = 5, MAX(quantity) = 15.
  2. Step 2: Match with options

    3, 30, 5, 15 matches all values correctly.
  3. Final Answer:

    3, 30, 5, 15 -> Option A
  4. Quick Check:

    COUNT=3, SUM=30, MIN=5, MAX=15 [OK]
Quick Trick: COUNT counts rows, SUM adds, MIN and MAX find extremes [OK]
Common Mistakes:
  • Mixing MIN and MAX values
  • Counting NULLs incorrectly
  • Swapping SUM and COUNT values

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PostgreSQL Quizzes