RelationalDBDesign
RelationalDBDesign

Select Statement
«Prev
Next»
## Advanced uses of the SELECT statement in SQL

### SQL GROUP Functions

### Example of SELECT COUNT (*)

One of the advanced uses of the Select statement is in Group functions.

Group functions are functions applied to a group of rows.

### Examples of Group Functions

Lesson 1

After you have a good understanding of what SQL can do, it is time to move on to more *sophisticated queries*.
It is important to understand what your database engine is capable of, and what your requirements are for pulling information from your system.

This module will introduce you to some of the more advanced queries used for extracting information from tables. These new clauses include

This module will introduce you to some of the more advanced queries used for extracting information from tables. These new clauses include

- grouping and
- filtering.

Group functions are built-in SQL functions that operate on groups of rows and return one value for the entire group.

These functions are:

SQL COUNT (): This function returns the number of rows in the table that satisfies the condition specified in the WHERE condition.

If the WHERE condition is not specified, then the query returns the total number of rows in the table.

For Example: If you want the number of drinks in a particular category, the query would be:

These functions are:

COUNT, MAX, MIN, AVG, SUM, DISTINCT

SQL COUNT (): This function returns the number of rows in the table that satisfies the condition specified in the WHERE condition.

If the WHERE condition is not specified, then the query returns the total number of rows in the table.

For Example: If you want the number of drinks in a particular category, the query would be:

SELECT COUNT (*) FROM fridge WHERE pop = 'Pepsi'; >

Group functions are functions applied to a group of rows.

COUNT(*) - Returns the number of rows in the group. MIN(exp) - Returns the minimum value of the expression evaluated on each row of the group. MAX(exp) - Returns the maximum value of the expression evaluated on each row of the group. AVG(exp) - Returns the average value of the expression evaluated on each row of the group.