Aggregate Functions : COUNT(), SUM(), AVG(), MIN(), MAX() | SQL- MySQL | Belayet Hossain

Aggregate Functions : COUNT(), SUM(), AVG(), MIN(), MAX() | SQL- MySQL | Belayet Hossain

Aggregate Functions in SQL :

Aggregate functions in SQL perform calculations on a set of rows and return a single summary value. These functions are commonly used with the GROUP BY clause to group rows based on one or more columns.


?? Common Aggregate Functions

  1. COUNT() : Returns the number of rows.
  2. SUM() : Calculates the total sum of a numeric column.
  3. AVG() : Returns the average value of a numeric column.
  4. MIN() : Returns the smallest value in a column.
  5. MAX() : Returns the largest value in a column.


→ Syntax

SELECT aggregate_function(column_name)

FROM table_name


?? 1.? COUNT () : Returns the number of rows in a table.

→ Example: Count the number of student in the student table.

→ Syntax:

select count(*) as total_student

from student

→ Output: total_student - 5


?? 2.????? AVG () Function: Returns the average value of a numeric column.

→ Example: Find the average salary of employees in the employee table.

→ Syntax:

select avg(salary) as Avg_Salary

from employee

Output: Avg_Salary - 38,750


?? 3.? SUM () : Calculates the total sum of a numeric column.

Example: Calculate the total salary of all employees in the employee table.

→ Syntax:

select sum(salary) as Total_salary

from employee

→ Output: Total_salary 155,000


?? 4.????? MIN () : Returns the smallest value in a column.

→ Example: Find the minimum salary in the Employees table.

Syntax:

select min(salary) as Min_Salary

from employee

→ output: Min_Salary 10,000


?? 5.????? MAX () : Returns the maximum value in a column.

→ Example: Find the maximum salary in the Employees table.

→ Syntax:

select max(salary) as Max_Salary

from employee

→ output: Max_Salary 55,000

?

?? Key Points

  1. Aggregate functions ignore NULL values (except COUNT(*)).
  2. Combine with GROUP BY for grouped results.
  3. Use HAVING for filtering aggregated data (not WHERE).


#dataanalytics #dataanalyst #SQL #MySQL #powerbi #AgrregateFucntion #AVg #SUM #COUNT #MIN #MAX #hiring #tech #data #career #job



Belayet Hossain ??

Data Analyst @ZnZ ? Power BI, SQL, Excel, Python (ETL), MySQL, Oracle, DBeaver ? Find insight & Making Decision ? Ex-Head of Quality Dept & 09 Y With smartphone Manufacturing & Service ? Ex- RFL, VIVO, Symphony ? EEE

2 个月

??

回复

要查看或添加评论,请登录

Belayet Hossain ??的更多文章

社区洞察

其他会员也浏览了