Hi,
I am trying to create a parameterized SQL (which I want to show on the dashboard) which will accept custom expressions. For instance, in the following query, >=
is hard-coded. I want to make this configurable. Say, users when looking at the dashboard, should be able to filter records with [ >, <, >=, <=, == ] and a numeric rating value.
SELECT count(*)
FROM products
WHERE rating >= {{rating}}
Any method through which this can be achieved? I tried making the expression a text field, like this:
SELECT count(*)
FROM products
WHERE rating {{operation}} {{rating}}
But in this case, the operation gets treated as a string, which forms an incorrect SQL, example:
SELECT count(*)
FROM products
WHERE rating ‘>=’ 4
Thanks,
Ashwin