Function Examples

You select from the following types of functions when you build an Expression (see ), a Where Clause (see Where Clause Builder), or a Having Clause (see Having Clause Builder).

Aggregate Functions

Depending on your database, may include: AVG, COUNT, MAX, MIN, STDEV, STDEVP, SUM, VAR, and VARP.

Example: AVG(emp.salary) returns the average employee salary from the table EMP.

System Functions

Depending on your database, may include: IFNULL and USERNAME.

Example: IFNULL(emp.commission_percent, 0) returns an employee’s commission percent; or, if the column is null, returns zero. The IFNULL function prevents the query from excluding null-value rows.

String Functions

Depending on your database, may include: UCASE/LCASE, CHAR, CONCAT, INSERT, LEFT/RIGHT, LENGTH, and other string functions.)

Example: UCASE(emp.ename) returns the employee name in all uppercase from the table EMP.

Time and Date Functions

Depending on your database, may include: YEAR, MONTH, QUARTER, WEEK, CURDATE, and other date functions.

Example: YEAR(emp.hiredate) returns the year an employee was hired, based on the hiredate column from the table EMP.

Numeric Functions

Depending on your database, may include: ABS, CEILING, FLOOR, MOD, SIGN, SQRT, and other mathematical or trigonometric functions.

Example: FLOOR(emp.commission_percent) returns the rounded-down integer value of an employee’s commission percent from the table EMP.