Finance[US] Career Guide Free Tutorials Go to Your University Placement Preparation 
0 like 0 dislike
4.6k views
in RTU/BTU B.Tech (CSE-IV Sem) DBMS Lab by Goeduhub's Expert (7.6k points)
Write the query for implementing the following functions: MAX(), MIN(), AVG() and COUNT().

1 Answer

0 like 0 dislike
by Goeduhub's Expert (7.6k points)
edited by
 
Best answer

Aggregate Functions

Aggregate Functions: Aggregate functions perform a calculation on a set of rows and return a single row. You can use aggregate functions as expressions only in the following clauses i.e., SELECT clause, HAVING clause. There are five aggregate functions: 

  • AVG() – returns the average value.
  • COUNT() – returns the number of values.
  • MAX() – returns the maximum value.
  • MIN() – returns the minimum value.
  • SUM() – returns the sum of all or distinct values.

AVG(): The AVG() function allows you to calculate the average value of a numeric column.

syntax : AVG(column)

SELECT AVG(SALARY) "AVERAGE SAL" FROM empl;

Output : 

AVERAGE SAL
22000.0000

COUNT(): The COUNT function returns the total number of values in the specified field.

syntax : COUNT(expression)

 SELECT COUNT(*) FROM empl; 

Output : 

count(*)
        6

MAX() : It returns the maximum value from the specified table field.

syntax : MAX(expression)

SELECT MAX(Salary) FROM empl;

Output : 

MAX(Salary)
     30000

MIN(): The MIN function returns the minimum value in the specified table field.

syntax : MIN(expression)

SELECT MIN(Salary)FROM empl;

Output : 

MIN(Salary)
       12000

SUM(): SUM function which returns the sum of all the values in the specified column. SUM works on numeric fields only. Null values are excluded from the result returned.

syntax : SUM(expression)

SELECT SUM(Salary) "Total Salary" from empl;

Output : 

Total Salary
132000

These functions are called aggregate functions because they operate on the aggregate of tuples. The result of an aggregate function is a single value.



For more Rajasthan Technical University CSE-IV Sem DBMS Lab Experiments CLICK HER
E

Learn & Improve In-Demand Data Skills Online in this Summer With  These High Quality Courses[Recommended by GOEDUHUB]:-

Best Data Science Online Courses[Lists] on:-

Claim your 10 Days FREE Trial for Pluralsight.

Best Data Science Courses on Datacamp
Best Data Science Courses on Coursera
Best Data Science Courses on Udemy
Best Data Science Courses on Pluralsight
Best Data Science Courses & Microdegrees on Udacity
Best Artificial Intelligence[AI] Courses on Coursera
Best Machine Learning[ML] Courses on Coursera
Best Python Programming Courses on Coursera
Best Artificial Intelligence[AI] Courses on Udemy
Best Python Programming Courses on Udemy

 Important Lists:

Important Lists, Exams & Cutoffs Exams after Graduation PSUs

 Goeduhub:

About Us | Contact Us || Terms & Conditions | Privacy Policy ||  Youtube Channel || Telegram Channel © goeduhub.com Social::   |  | 

 

Free Online Directory

...