I need to perform queries which check fields based on some arithmetic ops.
For example-
select a, b from table_name
where a + b == 10
Is there a way for this to be done?
I need to perform queries which check fields based on some arithmetic ops.
For example-
select a, b from table_name
where a + b == 10
Is there a way for this to be done?
Im trying this-
SELECT bucket, counter
FROM used_bucket_tracker
WHERE lounge_id = ?
AND bucket - counter <= ?
LIMIT 10
& I get-
:invalid_syntax, message: "line 4:4 no viable alternative at input ‘bucket’",
Even enclosing (bucket - counter) with the roud parentheses is useless, in that case it gives error-
:invalid_syntax, message: "line 4:4 no viable alternative at input ‘’",
As you realized, you can’t do this. Best is to pre-aggregate, so that you could then do WHERE key=? AND c=10
or, as in the latter example, WHERE key=? AND c <= ? LIMIT 10
This works, but of course, it assumes that the other fields (which then would’ve been pre-aggregated) don’t change. Otherwise, perhaps denormalizing to a counter table (if you’re ok w/ eventual consistency) and regular PN-Counter should eventually converge to a common state.