Query for records which have the city length > 20

I am looking for a way to query all leads which have the length of city__c > 20 characters in SOQL.

I cant seem to find anything like a length() in SOQL. Any workarounds? Or am i missing something obvious on the documentation

Answer

You need to create a new formula filed of type NUMBER and insert a simple formula to it that calculates a length of the string:

LEN(Street__c)

LEN Formula

Then you can query on this field:

Select ... From ...  Where FormulaField___c > 20

Attribution
Source : Link , Question Author : Prady , Answer Author : Sergej Utko

Leave a Comment