floor

Rounds a number toward negative infinity.

Syntax

floor(<expr>)

Arguments

ArgumentTypeDescription
<expr>floatInput value.

Returns

Returns float. Returns NULL if the input is NULL.

Usage notes

For an int or uint column, cast the value to float before calling this function.

Examples

Count full minutes watched in each video-view event, excluding the unfinished last minute.

VALUES ('view-17', 59.0), ('view-42', 120.0), ('view-63', 149.0)
SELECT $0 AS view_id, $1 AS watched_seconds
SELECT view_id, watched_seconds, floor(watched_seconds / 60.0) AS complete_minutes
+---------+-----------------+------------------+
| view_id | watched_seconds | complete_minutes |
+---------+-----------------+------------------+
| view-17 | 59.0            | 0.0              |
| view-42 | 120.0           | 2.0              |
| view-63 | 149.0           | 2.0              |
+---------+-----------------+------------------+