Skip to content

Instantly share code, notes, and snippets.

@toyeiei
Created Nov 9, 2018
Embed
What would you like to do?
SQL for Beginner - Aggregate Function
-- Find key statistics for column total in table invoices
SELECT
COUNT(total),
AVG(total),
SUM(total),
MIN(total),
MAX(total)
FROM invoices;
-- use AS to rename columns
SELECT
COUNT(total) AS count_invoice,
AVG(total) AS average_invoice,
SUM(total) AS sum_invoice,
MIN(total) AS min_invoice,
MAX(total) AS max_invoice
FROM invoices;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment