TGViewer
Data Analytics Data Analytics @sqlspecialist · 111K subscribers
Post #2428 10.8K
✅ Top 5 SQL Aggregate Functions with Examples 📊💡

1️⃣ COUNT()
Counts rows or non-null values—use COUNT(*) for total rows, COUNT(column) to skip nulls.
Example:
SELECT COUNT(*) AS total_employees FROM Employees;

Tip: In a 1k-row table, it returns 1k; great for validating data completeness.

2️⃣ SUM()
Adds up numeric values—ignores nulls automatically.
Example:
SELECT SUM(salary) AS total_salary FROM Employees;

Tip: For March orders totaling $60, it sums to 60; pair with WHERE for filtered totals like monthly payroll.

3️⃣ AVG()
Calculates average of numeric values—also skips nulls, divides sum by non-null count.
Example:
SELECT AVG(salary) AS average_salary FROM Employees;

Tip: Two orders at $20/$40 avg to 30; use for trends, like mean salary ~$75k in tech firms.

4️⃣ MAX()
Finds the highest value in a column—works on numbers, dates, strings.
Example:
SELECT MAX(salary) AS highest_salary FROM Employees;

Tip: Max order of $40 in a set; useful for peaks, like top sales $150k.

5️⃣ MIN()
Finds the lowest value in a column—similar to MAX but for mins.
Example:
SELECT MIN(salary) AS lowest_salary FROM Employees;

Tip: Min order of $10; spot outliers, like entry-level pay ~$50k.

Bonus Combo Query:
SELECT COUNT(*) AS total,
SUM(salary) AS total_pay,
AVG(salary) AS avg_pay,
MAX(salary) AS max_pay,
MIN(salary) AS min_pay
FROM Employees;


💬 Tap ❤️ for more!
  • ❤ 17
More from @sqlspecialist
  1. Oct 13, 2026📊 Data Analyst Interview Series — Part 9 Guys, let's continue our Data Analyst Interview…
  2. Oct 13, 2026𝗧𝗢𝗣 𝗙𝗥𝗘𝗘 𝗖𝗢𝗨𝗥𝗦𝗘𝗦 𝗧𝗢 𝗕𝗢𝗢𝗦𝗧 𝗬𝗢𝗨𝗥 𝗦𝗞𝗜𝗟𝗟𝗦 𝗜𝗡 𝟮𝟬𝟮𝟲! Explor…
  3. Oct 12, 20268️⃣ You receive a dataset with inconsistent date formats. How would you clean it? Sample A…
  4. Oct 12, 2026📊 Data Analyst Interview Series — Part 7 Guys, let's continue our Data Analyst Interview…
  5. Oct 12, 2026🚀 𝗪𝗵𝗶𝗰𝗵 𝗧𝗲𝗰𝗵 𝗦𝗸𝗶𝗹𝗹 𝗪𝗶𝗹𝗹 𝗬𝗼𝘂 𝗠𝗮𝘀𝘁𝗲𝗿 𝗶𝗻 𝟮𝟬𝟮𝟲? Want to buil…
  6. Oct 9, 2026“Here, the data is sorted by the second column in descending order and the first five rows…
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 →