How would I write the CQL to get the most recent set of data from each row?
I'm investigating transitioning from MSSQL to Cassandra and am starting to grasp the concepts. Lots of research has help tremendously, but I haven't found answer to this (I know there must be a way):
CREATE TABLE WideData {
ID text,
Updated timestamp,
Title text,
ReportData text,
PRIMARY KEY (ID, Updated)
} WITH CLUSTERING ORDER (Updated DESC)
INSERT INTO WideData (ID, Updated, Title, ReportData) VALUES ('aaa', NOW, 'Title', 'Blah blah blah blah')
INSERT INTO WideData (ID, Updated, Title, ReportData) VALUES ('bbb', NOW, 'Title', 'Blah blah blah blah')
wait 1 minute:
INSERT INTO WideData (ID, Updated, Title, ReportData) VALUES ('bbb', NOW, 'Title 2', 'Blah blah blah blah')
wait 3 minutes:
INSERT INTO WideData (ID, Updated, Title, ReportData) VALUES ('aaa', NOW, 'Title 2', 'Blah blah blah blah')
wait 5 minutes:
INSERT INTO WideData (ID, Updated, Title, ReportData) VALUES ('aaa', NOW, 'Title 3', 'Blah blah blah blah')
How would I write the CQL to get the most recent set of data from each row?
SELECT ID, Title FROM WideRow - gives me 5 rows, as it pivots the data for me.
Essentially I want the results for (SELECT ID, Title FROM WideRow WHERE .....) to be:
ID Title
aaa, Title3
bbb, Title2
Also, is there a way to get a count of the number of data sets in a wide row?
Essentially the equivalent of TSQL: SELECT ID, Count(*) FROM Table GROUP BY ID
ID Count
aaa 3
bbb 2
Thanks
Also, any references to learn more about these types of queries would also be appreciated.