Search⌘ K
AI Features

Seeing the Big Picture: SUM, AVG, and COUNT

Explore how to use SQL aggregate functions SUM AVG and COUNT to summarize and analyze data. Learn to write queries that calculate totals averages and counts, apply filters, and interpret results for practical data insights.

Step 1: Start with a question

So far, you’ve been exploring individual rows—every employee, every record. Now let’s think bigger.

What if you asked: What’s the total salary cost for the company?

Instead of listing all employees, you want a single number, the total sum of all salaries.

Prompt: Write a SQL query that calculates the total of all salaries from the employees table.

Powered by AI
5 Prompts Remaining
Prompt AI WidgetOur tool is designed to help you to understand concepts and ask any follow up questions. Ask a question to get started.

Step 2: Run and observe

AI will likely produce:

MySQL
SELECT SUM(salary) AS "Total Salary Cost"
FROM employees;

Run it. You’ll see a single number.

Reflect:

    ...