Andrew Tang
Andrew Tang

Reputation: 111

how to convert text to number in a SOQL query?

Can somebody please help me figure out what is wrong with this query?

https://data.cityofnewyork.us/resource/i4gi-tjb9.json?$where=speed<10

It failed with error code: query.soql.type-mismatch

the "speed" column of the table is declared as text. I am having trouble in converting speed to a real (decimal) number for the comparison. Thanks

Upvotes: 2

Views: 2463

Answers (2)

Ben Shoval
Ben Shoval

Reputation: 1750

Put the number in parenthesis, like this:

https://data.cityofnewyork.us/resource/i4gi-tjb9.json?$where=speed<"10"

or if you need it url encoded, use this:

https://data.cityofnewyork.us/resource/i4gi-tjb9.json?$where=speed%3C%2210%22

Upvotes: 0

chrismetcalf
chrismetcalf

Reputation: 1566

Try casting the column with ::number, like this:

GET https://data.cityofnewyork.us/resource/i4gi-tjb9.json?$where=speed::number > 31.69

Upvotes: 1

Related Questions