SQLite Forum

Proposal: Implement the MOD(x, y) function
Login

Proposal: Implement the MOD(x, y) function

(1.2) By tarest on 2021-04-15 10:15:32 edited from 1.1 [link]

I compared scalar SQL functions in 5 different RDBMS: **PostgreSQL**, **MySQL**, **Oracle**, **SQL Server** and **SQLite**, and also in the [ANSI SQL Standard](https://en.wikipedia.org/wiki/SQL#Standardization_history). There are large differences among different RDBMS, and I propose to reduce them a little bit.

The ANSI SQL Standard defines the `MOD(x, y)` function which returns division remainder. It is already implemented in PostgreSQL, MySQL, and Oracle. Currently, SQL Server and SQLite implement only modulo operator: `x % y`.

For more information about comparing implementations of the scalar functions, click here: [https://github.com/iwis/SQL-notes/blob/master/Functions.txt](https://github.com/iwis/SQL-notes/blob/master/Functions.txt)

(2) By Larry Brasfield (larrybr) on 2021-04-15 10:22:32 in reply to 1.2

Have you proposed this despite <u>[such a function already existing in SQLite](https://sqlite.org/lang_mathfunc.html#mod)</u>? Or do you find some deficiency in the implementation? If that's the case, please be specific.

(3) By anonymous on 2021-04-15 16:06:56 in reply to 2 [link]

I think OP is still using a pre 3.35 version .....

(4) By ThanksRyan on 2021-04-15 16:46:56 in reply to 1.2 [link]

See the [3.35.0 release notes][1]:

Item number one:

> Added built-in SQL math functions(). (Requires the -DSQLITE_ENABLE_MATH_FUNCTIONS compile-time option.) 

[1]:https://www.sqlite.org/releaselog/3_35_0.html