0% found this document useful (0 votes)
12 views4 pages

Aggregate Functions

aggregate functions in netbeans

Uploaded by

prachi.sk07
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views4 pages

Aggregate Functions

aggregate functions in netbeans

Uploaded by

prachi.sk07
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

MYSQL

Aggregate Functions: These functions are also known as Multiple Row Functions or Group
Functions.
These functions operate on a set of rows to return a single value. These functions are:
Aggregate (Group) Functions :
Points to remember
In Count function , when the argument is a column name or an expression based on a column ,
count() returns the number of non – NULL values in that column.
If the argument is a *, then count() returns the total number of rows in a table, including
duplicates and nulls.
e.g. Assume table SHOES contains 13 rows then the query
SELECT COUNT(*) FROM SHOES; gives output as 13 indicating that there are 13 records in
the SHOES table. Whereas the query SELECT COUNT(MARGIN) FROM SHOES where
MARGIN is a column gives output as 10 indicating that there are 10 values in the MARGIN
column of SHOES table and remaining(3) are NULL values.

Also SELECT COUNT(DISTINCT CITY) FROM MEMBERS : Here distinct is used to count
the number of distinct cities in CITY column whereas SELECT COUNT(ALL CITY) FROM
MEMBERS : Here all is used to count the entries including repeats ignoring NULL values.
All other aggregate functions such as sum, max,min,avg ignores NULL values of a
column.

GROUP BY : is used in a SELECT statement in conjunction with aggregate functions to group


the result based on distinct values in a column.
HAVING : clause is used in conjunction with GROUP BY clause in a SELECT statement to
put conditions on groups.
WHERE Vs HAVING : WHERE is used to put condition on individual row of a table whereas
HAVING is used to put condition on individual group formed by GROUP BY clause in a
SELECT statement.

You might also like