Articles → SQL SERVER → Aggregate Functions In SQL Server

Aggregate Functions In SQL Server






Purpose






  1. Sum
  2. Avg
  3. Max
  4. Count



Student, Subject and Marks tables


Student_IDStudent_Name
1Karan
2Sumit
3Ashish


Subject_IDSubject_Name
1Mathematics
2Social Studies
3General Science


Primary_Key_IDStudent_IDSubject_IDMarks
11185
21265
31360



Sum


select sum(Marks) from Marks where Student_ID = 1




Picture showing the output of sum aggregate function in sql server



Avg


select avg(Marks) from Marks where Student_ID = 1




Picture showing the output of avg aggregate function in sql server



Max


select max(Marks) from Marks where Student_ID = 1




Picture showing the output of avg aggregate function in sql server



Count


select count(*) from Marks where Student_ID = 1




Picture showing the output of avg aggregate function in sql server





Posted By  -  Karan Gupta
 
Posted On  -  Monday, March 29, 2010

Query/Feedback


Your Email Id
 
Subject
 
Query/FeedbackCharacters remaining 250