Reputation: 13
I have stats table. stat_date, views (counter), amount (decimal)
I want to multiply fields and aggregate. It works like this in MySQL.
SELECT SUM(views * amount) FROM stats;
But not work on cassandra. Is there a function or an udf for it?
Thanks.
I created udf function for this problem. So this works great.
CREATE OR REPLACE FUNCTION multiplication(input1 counter, input2 double)
CALLED ON NULL INPUT RETURNS double
LANGUAGE java AS 'return input1 * input2;';
And sum all rows.
SELECT SUM(multiplication(views, amount)) FROM stats;
Upvotes: 1
Views: 1138
Reputation: 12830
You can't query like this in cassandra.
All the aggregate function in cassandra (min, max, avg, sum, and count) function received only column name and constant as parameter, nothing else.
Upvotes: 1