You need to sign in to do that
Don't have an account?
kmorf_entransform
Trying to filter a query by values greater than and less than a certain value
im trying to execute a query based on a certain range of numbers. for example we want to query Amount > 100 and < 500.
Im trying to execute this code but im getting an error saying;
EXCEPTION_THROWN|[110]|System.QueryException: Invalid bind expression type of String for column of type Decimal
Double grtValue = Double.valueOf(selectedAmountGrt);
Double lessValue = Double.valueOf(selectedAmountLess);
Select Amount from Opportunity where Avg_Annual_Volume__c >: grtValue OR Avg_Annual_Volume__c < : lessValue';
Hi Pradeep, that is incorrect, Apex script variables and expressions can be used in SOQL only if preceded by a colon, otherwise you get a syntax error.
All Answers
The query looks fine to me, assuming Avg_Annual_Volume__c is a number field with decimals. Could you put a system.debug before the query to print the 2 double values and see what they are getting.
Hello there!!
This error is probably in the query itself, Lets see, I think you don need to use the colon
Select Amount from Opportunity where Avg_Annual_Volume__c > grtValue OR Avg_Annual_Volume__c < lessValue;
The above is your query, I have just removed : Give it a try, Hope it helps!!
Hi Pradeep, that is incorrect, Apex script variables and expressions can be used in SOQL only if preceded by a colon, otherwise you get a syntax error.