MOD

Applies to: ✅ Data 360 SQL ✅ Tableau Hyper API

Returns the remainder of a division.

Syntax 

1mod(<y>, <x>)

Arguments 

Required 

  • <y>: The dividend.
  • <x>: The divisor.

Returns 

Returns the remainder of y/x by using the same data type as the input. Returns bigint for numeric input.

Considerations 

  • The result takes the sign of the dividend (y). For example, mod(-9, 4) returns -1.
  • A divisor (x) of zero returns an error.

Examples 

Get a Remainder 

Compute the remainder of a division.

1SELECT mod(9, 4) AS result;

Returns 1.

Remainder of a Negative Dividend 

The result takes the sign of the dividend.

1SELECT mod(-9, 4) AS result;

Returns -1.

Related Documentation