Over 10 years we helping companies reach their financial and branding goals. Onum is a values-driven SEO agency dedicated.

CONTACTS
ECET 2026 CSE

Day 43 – Evening Session: DBMS – SQL GROUP BY, HAVING & Aggregate Functions – ECET 2026

SQL is a very important part of DBMS section in ECET 2026. Topics like GROUP BY, HAVING, Aggregate Functions are repeated every year. With practice, these questions can be scored directly.


📘 Concept Notes

🔹 Aggregate Functions in SQL

Aggregate functions perform calculations on a set of values and return a single value.

Common aggregate functions:

  • COUNT() → returns number of rows.
  • SUM() → returns total of values.
  • AVG() → returns average value.
  • MIN() → returns smallest value.
  • MAX() → returns largest value.

Formula for AVG:

 AVG(X) = \dfrac{\text{SUM}(X)}{\text{COUNT}(X)}


🔹 GROUP BY Clause

  • Groups rows that have the same values into summary rows.
  • Often used with aggregate functions.

Syntax:

SELECT column_name, AGG_FUNC(column_name)
FROM table_name
GROUP BY column_name;

Example:

SELECT dept, COUNT(*)
FROM Employees
GROUP BY dept;

👉 Gives number of employees in each department.


🔹 HAVING Clause

  • Used to filter groups created by GROUP BY.
  • WHERE cannot be used with aggregate functions, so we use HAVING.

Example:

SELECT dept, AVG(salary)
FROM Employees
GROUP BY dept
HAVING AVG(salary) > 50000;

👉 Displays only departments where average salary > 50,000.


⚙️ Important Points

  • WHERE filters rows before grouping.
  • HAVING filters groups after aggregation.
  • Aggregate functions ignore NULL values.

🔟 10 Expected MCQs – ECET 2026

Q1. Which SQL clause is used to group records?
A) ORDER BY
B) GROUP BY
C) HAVING
D) DISTINCT

Q2. Aggregate functions return:
A) Multiple values
B) A single value
C) Only text values
D) Only numeric values

Q3. Formula for average is:
A) SUM / MIN
B) SUM / COUNT
C) MAX / SUM
D) COUNT / SUM

Q4. Which aggregate function counts rows ignoring NULL values?
A) COUNT(column)
B) COUNT(*)
C) MAX()
D) MIN()

Q5. HAVING clause is used with:
A) Joins
B) GROUP BY
C) Subqueries
D) Triggers

Q6. Which is evaluated first in SQL?
A) GROUP BY
B) HAVING
C) WHERE
D) ORDER BY

Q7. Output of SELECT COUNT(*) FROM Students; is:
A) Total number of rows including NULLs
B) Total number of non-NULL rows only
C) Minimum row value
D) Error

Q8. If a table has salaries: 2000, 3000, 4000 → AVG(salary) = ?
A) 2000
B) 3000
C) 4000
D) 9000

Q9. In SQL, HAVING clause filters:
A) Rows before aggregation
B) Groups after aggregation
C) Columns before selection
D) Rows after ordering

Q10. Which one is NOT an aggregate function?
A) SUM
B) AVG
C) CONCAT
D) MAX


✅ Answer Key

Q.NoAnswer
Q1B
Q2B
Q3B
Q4A
Q5B
Q6C
Q7A
Q8B
Q9B
Q10C

🧠 Explanations

  • Q1 → B: GROUP BY is used for grouping.
  • Q2 → B: Aggregate functions always return a single value.
  • Q3 → B: Average = SUM / COUNT.
  • Q4 → A: COUNT(column) ignores NULLs; COUNT(*) counts all rows.
  • Q5 → B: HAVING filters groups formed by GROUP BY.
  • Q6 → C: WHERE is applied before grouping.
  • Q7 → A: COUNT(*) counts all rows including NULLs.
  • Q8 → B:  AVG = \dfrac{2000+3000+4000}{3} = 3000 .
  • Q9 → B: HAVING filters groups after aggregation.
  • Q10 → C: CONCAT is a string function, not aggregate.

🎯 Why Practice Matters

  • GROUP BY + HAVING are standard SQL exam questions.
  • Aggregate functions are easy scoring if you remember formulas.
  • SQL query questions test both syntax and logic order (WHERE → GROUP BY → HAVING → ORDER BY).

📲 Join Our ECET Prep Community on WhatsApp

👉 Join WhatsApp Group – Click Here

Leave a comment

Your email address will not be published. Required fields are marked *