0 day streak
sql / beginner
Snippet

Summarizing Numeric Data Using Aggregate Functions

Aggregate functions like COUNT and AVG compute a single result value from a set of input values across multiple table rows.

snippet.sql
sql
1
2
3
4
SELECT
COUNT(*) AS total_orders,
AVG(amount) AS average_amount
FROM orders;
Breakdown
1
SELECT
Specifies the summary fields to calculate and retrieve.
2
COUNT(*) AS total_orders,
Counts all rows in the orders table and names the result total_orders.
3
AVG(amount) AS average_amount
Calculates the average value of the amount column across all rows.
4
FROM orders;
Identifies orders as the source table for the aggregate calculation.