I'm trying to get all the file_id
items for the most recent version
for the specified folder_id
for the example_table
defined below in Cassandra. Is this possible, or is my data designed incorrectly for my use case?
example_table
folder_id (Partition Key) |
file_id (Clustering Key) |
version (timestamp Clustering Key) ORDER DESC |
---|---|---|
1 | 1 | 2 |
1 | 1 | 1 |
1 | 2 | 2 |
1 | 2 | 1 |
1 | 3 | 2 |
1 | 3 | 1 |
I'm thinking the query would be something like this, but I'm not able to get it working.
SELECT folder_id,file_id,MAX(version) FROM example_table WHERE folder_id=1;
desired result
folder_id (Partition Key) |
file_id (Clustering Key) |
version (timestamp Clustering Key) ORDER DESC |
---|---|---|
1 | 1 | 2 |
1 | 2 | 2 |
1 | 3 | 2 |