Bird
0
0

Which SQL statement correctly computes the average cost from a table named Inventory?

easy📝 Conceptual Q2 of 15
SQL - Aggregate Functions
Which SQL statement correctly computes the average cost from a table named Inventory?
ASELECT AVERAGE(cost) FROM Inventory;
BSELECT AVG(cost) FROM Inventory;
CSELECT MEAN(cost) FROM Inventory;
DSELECT SUM(cost)/COUNT(*) FROM Inventory;
Step-by-Step Solution
Solution:
  1. Step 1: Identify correct function

    SQL uses AVG() to calculate average values.
  2. Step 2: Check syntax

    SELECT AVG(cost) FROM Inventory; is correct syntax.
  3. Step 3: Evaluate other options

    AVERAGE() and MEAN() are invalid SQL functions; SELECT SUM(cost)/COUNT(*) FROM Inventory; calculates average manually but is less efficient.
  4. Final Answer:

    SELECT AVG(cost) FROM Inventory; -> Option B
  5. Quick Check:

    AVG() is standard average function [OK]
Quick Trick: Use AVG() to calculate average in SQL [OK]
Common Mistakes:
MISTAKES
  • Using non-existent functions like AVERAGE() or MEAN()
  • Trying to manually calculate average instead of using AVG()
  • Syntax errors in function usage

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More SQL Quizzes