MOD

The MOD function returns the modulo or remainder of the division between two numeric values.

MOD Syntax

Use the following syntax when incorporating MOD functions in queries:

MOD(expression1, expression2)

Where expression1 is the dividend, the value that will be divided by expression2. And expression2 is the divisor, the value to divide expression1 by.

Note: The calculation of negative operands depends on C++ and your underlying hardware. AnzoGraph uses FMOD for floating point operands and % for all other data types.

MOD Examples

The example queries in this section run against the AnzoGraph sample Tickit data set, which captures sales activity for a fictional Tickit website where people buy and sell tickets for sporting events, shows, and concerts. You can load and explore this data set. For more information, see Working with the Tickit Data.

The following example queries the sample Tickit dataset to find the modulo between the number of seats in each venue and the population of the city the venue is in.

SELECT ?venue ?city (MOD(?pop, ?seats) AS ?modulo)
FROM <tickit>
WHERE {
  ?s <venuename> ?venue .
  ?s <venuecitypop> ?pop .
  ?s <venuecity> ?city .
  ?s <venueseats> ?seats .
}
ORDER BY ?venue
venue                          | city            | modulo
-------------------------------+-----------------+--------
ARCO Arena                     | Sacramento      |    638
AT&T Park                      | San Francisco   |  16678
Angel Stadium of Anaheim       | Anaheim         |  26011
Arrowhead Stadium              | Kansas City     |  62532
Bank of America Stadium        | Charlotte       |  71742
Busch Stadium                  | St. Louis       |  20109
Citizens Bank Park             | Philadelphia    |  42008
Cleveland Browns Stadium       | Cleveland       |  30815
Comerica Park                  | Detroit         |   3483
Coors Field                    | Denver          |  45263
...
58 rows