mechatroner / RBQL

🦜RBQL - Rainbow Query Language: SQL-like query engine for (not only) CSV file processing. Supports SQL queries with Python and JavaScript expressions.
https://rbql.org
MIT License
276 stars 13 forks source link

How can I compare with integers? #9

Closed MartinThoma closed 5 years ago

MartinThoma commented 5 years ago

I tried

SELECT a3, a11 WHERE a11 > '10'

But then I also get results where a11 = 2.

What I would like to do:

SELECT a3, a11 WHERE int(a11) > '10'

mechatroner commented 5 years ago

Hi @MartinThoma If you use Python backend, then: SELECT a3, a11 WHERE int(a11) > 10 for JavaScript backend: SELECT a3, a11 WHERE parseInt(a11) > 10 Basically you don't need to quote 10 just like you don't do it for number comparison in Python or JS code.

BTW for JS you can also use less explicit expression: SELECT a3, a11 WHERE a11 > 10 Because JS implicitly converts strings to numbers when comparing them with integers, see https://www.w3schools.com/js/js_comparisons.asp