There is a field of type double and it can have a max of 2 decimal places (as per field definition). But extra decimals were added to some of the records via API. I wish to extract such records where more than 2 decimals are present. I did not find a way to query for it in SOQL.

Can you suggest a way to do it? Thanks.

2 Answers 2


Another approach without creating new fields as in the previous answer.

There is no way to do it using only SOQL query, however, if you can achieve this running a script in dev console like this (assume that your object is Object__c and your Decimal field is Field__c):

for (Object__c obj : [SELECT Id, Field__c FROM Object__c WHERE Field__c != NULL]) {
    if (obj.Field__c * 100 != Math.round(obj.Field__c * 100)) {

SOQL cannot do this on its own. The standard approach of creating a formula field to assist you ought to work though.

That is to say you should create a checkbox formula field which can detect when there is a different precision in your field value than expected. You'll then be able to use it in the WHERE clause to achieve your end goal.

The ROUND() function is what I imagine you'd use (check to see if rounding to 2 decimals is the same as the un-rounded value).

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .