Select to view content in your preferred language

Why is MOD(OBJECTID,30)=0 an invalid expression?

972
5
11-07-2019 08:52 PM
ElectraNetArcGIS
New Contributor

Why is MOD(OBJECTID,30)=0 an invalid expression?

I have a feature class with a field 'OBJECTID', it appears automatically when typing the SQL syntax. I tried this in v2.4 and 2.3. Both places it says invalid syntax. It works, however, in another map. The first OBJECTID value is 281. There are 290 records. If i create another field (LONG data type) and subtract 280 from the OBJECTID field and put the result in this new field, so it starts at 1, and then use that field in the MOD expression, it still fails. The data comes from a SDE.

Tags (1)
0 Kudos
5 Replies
DanPatterson_Retired
MVP Emeritus

I hate queries.  I prefer to add a field to the table so I have a record of whether a condition was met.

math.fmod(!OBJECTID!,2) == 0.0  # check for divisible by 2, returns 0 or 1
JoshuaBixby
MVP Esteemed Contributor

Often times with enterprise geodatabases, the syntax is dependent on the specific DBMS.  What DBMS are you using?

KoryKramer
Esri Community Moderator

It worked for me in file gdb:

0 Kudos
JoshuaBixby
MVP Esteemed Contributor

I was picking up on the "data comes from a SDE" part of the question.  If the data is coming from SQL Server, MOD is not recognized, which may or may not be the issue.

curtvprice
MVP Esteemed Contributor

SQL Server MOD is %:

OBJECTID % 30 = 0