TGViewer
Data Analytics Data Analytics @sqlspecialist ยท 111K subscribers
Post #2136 3.94K
๐Ÿ“Š Aggregate Functions (COUNT, SUM, AVG, MIN, MAX)

Aggregate functions are used to perform calculations on multiple rows of a table and return a single value. They're mostly used with GROUP BY, but also work standalone.

1. COUNT()
Returns the number of rows.

Example:

SELECT COUNT(*) FROM employees;

Counts all employees in the table.

You can also count only non-null values in a column:

SELECT COUNT(email) FROM customers;


2. SUM()
Adds up all the values in a numeric column.

Example:

SELECT SUM(salary) FROM employees;

Gives you the total salary payout.


3. AVG()
Calculates the average value of a numeric column.

Example:

SELECT AVG(price) FROM products;

Finds the average product price.


4. MIN()
Returns the lowest value.

Example:

SELECT MIN(salary) FROM employees;

Finds the smallest salary.


5. MAX()
Returns the highest value.

Example:

SELECT MAX(salary) FROM employees;

Finds the highest salary in the table.


Bonus Example:

SELECT
COUNT(*) AS total_orders,
SUM(amount) AS total_revenue,
AVG(amount) AS avg_order_value
FROM orders;

This gives you a quick business summary: number of orders, total revenue, and average order value.


React with โค๏ธ for more.

Share with credits: https://t.me/sqlspecialist

Hope it helps :)
  • โค 10
  • ๐Ÿ‘ 1
More from @sqlspecialist
  1. Oct 18, 2026๐Ÿฐ ๐—™๐—ฅ๐—˜๐—˜ ๐—–๐—ผ๐˜‚๐—ฟ๐˜€๐—ฒ๐˜€ ๐—ง๐—ผ ๐— ๐—ฎ๐˜€๐˜๐—ฒ๐—ฟ ๐—–๐—ผ๐—ฑ๐—ถ๐—ป๐—ด ๐—™๐—ผ๐—ฟ ๐—™๐—ฅ๐—˜๐—˜๐Ÿ˜ โœ… 100% FREE Yoโ€ฆ
  2. Oct 17, 2026Sales Fact โ†“ Customer Dimension Product Dimension Date Dimension Region Dimension The factโ€ฆ
  3. Oct 17, 2026๐Ÿ“Š Data Analyst Interview Series โ€” Part 11 Guys, let's continue our Data Analyst Interviewโ€ฆ
  4. Oct 17, 2026๐—œ๐—•๐—  ๐—™๐—ฅ๐—˜๐—˜ ๐—ง๐—˜๐—–๐—› ๐—–๐—ข๐—จ๐—ฅ๐—ฆ๐—˜๐—ฆ ๐Ÿฎ๐Ÿฌ๐Ÿฎ๐Ÿฒ! ๐ŸŽ“ Explore IBM Cognitive Class and buildโ€ฆ
  5. Oct 16, 2026๐——๐—ฎ๐˜๐—ฎ ๐˜€๐—ฐ๐—ถ๐—ฒ๐—ป๐—ฐ๐—ฒ ๐—–๐—ฒ๐—ฟ๐˜๐—ถ๐—ณ๐—ถ๐—ฐ๐—ฎ๐˜๐—ถ๐—ผ๐—ป ๐—ช๐—ถ๐˜๐—ต ๐—”๐—œ๐Ÿ˜ Future Ready Data Scienโ€ฆ
  6. Oct 14, 2026I could then categorize customers into groups such as Active, At Risk, and Inactive and suโ€ฆ
Threads Profile ViewerView any public Threads profile without an account.Open ThreadLook โ†’Writing with AI? Make it sound human.Metric37 rewrites AI drafts so they read naturally. Free AI detector, 1,500 words free.Try Metric37 โ†’