MySQL provides built-in functions that perform special operations.

Aggregate functions operate on a set of data. These are usually used to perform some action on a complete set of returned rows. For example, `SELECT AVG(height) FROM kids`

would return the average of all the values of the `height`

field in the `kids`

table. `AVG( )`

, `COUNT( )`

, and `SUM( )`

allow `DISTINCT`

.

`AVG(`

expression`)`

Returns the average value of the values in expression (e.g.,

`SELECT AVG(score) FROM tests`

).`BIT_AND(`

expression`)`

Returns the bitwise

`AND`

aggregate of all the values in expression (e.g.,`SELECT BIT_AND(flags) FROM options`

). A bit will be set in the result if and only if the bit is set in every input field.`BIT_OR(`

`expression`

`)`

Returns the bitwise

`OR`

aggregate of all the values in(e.g.,`expression`

`SELECT BIT_OR(flags) FROM options`

). A bit is set in the result if it is set in at least one of the input fields.`BIT_XOR(`

`expression`

`)`

Returns the bitwise

`XOR`

aggregate of all the values inwith 64-bit precision.`expression`

`COUNT(`

`expression`

`)`

Returns the number of times

was not null.`expression`

`COUNT(*)`

will return the number of rows with some data in the entire table (e.g.,`SELECT COUNT(*) FROM folders`

).`GROUP_CONCAT([DISTNCT]`

`expression`

`[ORDER BY {`

`column`

`|`

`expression`

`}] [SEPARATOR`

`sep`

`])`

Provides a string that combines in order all the results marked by

.`expression`

`MAX(`

`expression`

`)`

Returns the largest value in

(e.g.,`expression`

`SELECT MAX (elevation) FROM mountains`

).`MIN(`

`expression`

`)`

Returns the smallest value ...

Start Free Trial

No credit card required