CREATE TABLE test1 ( username text, activity_timestamp timestamp, activity_id text, amount int, PRIMARY KEY (username,activity_timestamp,activity_id) ) WITH CLUSTERING ORDER BY (activity_timestamp DESC, activity_id ASC);
The requirement is to generate a report to pull out all those records for the day which have amount less than 500. How can this be achieved from the existing model? (without having to create a new table)
A possible solution:
By executing shell script that hits all partitions of the table-->
user_list=`cqlsh -e "select distinct username from test1" ` current_date="$(date +'%Y-%m-%d')" for user_id in ${user_list[@]} do dsbulk unload -delim ';' -query "select * from test1 where username='$user_id' and activity_timestamp>'$current_date';" | awk -F ';' '$2 <=500 && $2>=100'
Is there a better efficient way ?