MySQL SUM Function

Example

Return the sum of the “Quantity” field in the “OrderDetails” table:

SELECT SUM(Quantity) AS TotalItemsOrdered FROM OrderDetails;

Definition and Usage

The SUM() function calculates the sum of a set of values.

Note: NULL values are ignored. Continue reading MySQL SUM Function

MySQL SQRT Function

Example

Return the square root of a number:

SELECT SQRT(64);

Definition and Usage

The SQRT() function returns the square root of a number. Continue reading MySQL SQRT Function

MySQL SIN Function

Example

Return the sine of a number:

SELECT SIN(2);

Definition and Usage

The SIN() function returns the sine of a number. Continue reading MySQL SIN Function

MySQL ROUND Function

Example

Round the number to 2 decimal places:

SELECT ROUND(135.375, 2);

Definition and Usage

The ROUND() function rounds a number to a specified number of decimal places.

Continue reading MySQL ROUND Function

MySQL RAND Function

Example

Return a random decimal number (no seed value – so it returns a completely random number >= 0 and <1):

SELECT RAND();

Definition and Usage

The RAND() function returns a random number between 0 (inclusive) and 1 (exclusive). Continue reading MySQL RAND Function

MySQL RADIANS Function

Example

Convert a degree value into radians:

SELECT RADIANS(180);

Definition and Usage

The RADIANS() function converts a degree value into radians.

Continue reading MySQL RADIANS Function

MySQL POWER Function

Example

Return 4 raised to the second power:

SELECT POWER(4, 2);

Definition and Usage

The POWER() function returns the value of a number raised to the power of another number.

Continue reading MySQL POWER Function

MySQL POW Function

Example

Return 4 raised to the second power:

SELECT POW(4, 2);

Definition and Usage

The POW() function returns the value of a number raised to the power of another number.

 

Syntax

POW(x, y)

Parameter Values

Parameter Description
x Required. A number (the base)
y Required. A number (the exponent)

Technical Details

Works in: From MySQL 4.0

More Examples

Example

Return 8 raised to the third power:

SELECT POW(8, 3);

MySQL PI Function

Example

Return the value of PI:

SELECT PI();

Definition and Usage

The PI() function returns the value of PI.

Continue reading MySQL PI Function