Skip to content
Exercises · Q7

Q.Name the five aggregate functions in SQL and state what each returns. Explain the difference between COUNT(*) and COUNT(column).

ChseodishaTextbookSubjectiveImportance★★★★★est
25% · 4/16 Questions
🔒 Locked · start free trial →

You're viewing a preview — the full solution, concept, methods & PYQ mapping are locked.

Start your 14-day free trial to unlock the full solution →

Aggregate (group) functions take a whole column of values and return a single summary value. The five standard ones are:

  • COUNT() — the number of rows.
  • SUM(column) — the total of the values in a numeric column.
  • AVG(column) — the average (mean) of the values in a numeric column.
  • MAX(column) — the largest value in the column.
  • MIN(column) — the smallest value in the column.

Difference between COUNT(*) and COUNT(column): COUNT(*) counts all the rows in the result, including rows that contain NULLs. COUNT(column) counts only the rows where that particular column is not NULL. For our Employee table, COUNT(*) gives 6 (all employees), but COUNT(Salary) gives 5, because one employee's salary is NULL and is therefore not counted. …

Unlock everything free for 14 days

  • Full step-by-step solutions
  • Concept-first explanations
  • Methods, shortcuts & mistakes
  • PYQ mapping + timed mock tests

Full access for 14 days. No credit card required.