Aggregation Operations in DBMS – COUNT, SUM, AVG, MAX, MIN with Examples

Aggregation Operations in Relational Algebra

Aggregation operations are used to summarize data in a relation. Common aggregation functions include COUNT, SUM, AVG, MAX, MIN. These operations are essential for generating totals, averages, maximum or minimum values, and counts in datasets.


Common Aggregation Functions

  • COUNT: Counts the number of tuples.
  • SUM: Calculates the total of numeric attributes.
  • AVG: Computes the average value of numeric attributes.
  • MAX: Finds the maximum value.
  • MIN: Finds the minimum value.

Example Dataset (Bangladeshi Data)

StudentCourseMarks
ArifDBMS85
ArifNetworking90
RafiDBMS78
RafiNetworking88
SadiaDBMS92
SadiaAI95

Example Queries and Results

1. Average Marks of Each Student

AVG(Marks) GROUP BY Student
StudentAverage Marks
Arif87.5
Rafi83
Sadia93.5

2. Maximum Marks in DBMS

MAX(Marks) WHERE Course='DBMS'

Result: 92

3. Total Marks of Arif

SUM(Marks) WHERE Student='Arif'

Result: 85 + 90 = 175

4. Count of Students per Course

COUNT(Student) GROUP BY Course
CourseNumber of Students
DBMS3
Networking2
AI1

Key Points

  • Aggregation functions summarize numeric or countable data.
  • GROUP BY is used to calculate aggregates per category.
  • Aggregation is widely used in analytics, reporting, and dashboards.

Summary Table of Aggregation Functions

FunctionDescription
COUNTCounts number of tuples
SUMCalculates total of numeric attribute
AVGCalculates average value
MAXFinds maximum value
MINFinds minimum value

dbms aggregation operations, relational algebra aggregation example, count sum avg max min bangladesh, advanced dbms queries

কোন মন্তব্য নেই:

একটি মন্তব্য পোস্ট করুন