MySQL ADDDATE Function

Example

Add 10 days to a date and return the date:

SELECT ADDDATE("2017-06-15", INTERVAL 10 DAY);

Definition and Usage

The ADDDATE() function adds a time/date interval to a date and then returns the date. Continue reading MySQL ADDDATE Function

MySQL TRUNCATE Function

Example

Return a number truncated to 2 decimal places:

SELECT TRUNCATE(135.375, 2);

Definition and Usage

The TRUNCATE() function truncates a number to the specified number of decimal places.

Continue reading MySQL TRUNCATE Function

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