Hello Rahul 1) If your query pattern is to always request the last events, change your clustering order to "DESC": WITH CLUSTERING ORDER BY (*"eventTime"* DESC);
2) To get the last or N last events, use the LIMIT clause of CQL3: select* ... *ORDER BY* "eventTime"* DESC LIMIT 1; 3) I believe the value "eventTime" corresponds to the time the event is created right ? Would'nt it be sufficient to consider this value also as the write time for the event ? Do you really need to distinguish between event creation time and event write time ? If such distinction is not necessary, you may use use eventTime and get rid of the writetime() function Regards Duy Hai DOAN On Thu, Jan 30, 2014 at 7:30 PM, Rahul Gupta <rgu...@dekaresearch.com>wrote: > I am trying to find last value inserted in a Cassandra1.2 table using > CQL3 but can't find a solution. > > > > There is WRITETIME(<col name>) but that gives me time when that column was > written. > > > > > > CREATE TABLE* "dev"."eventTable"* ( > > * "eventName"* text, > > * "eventTime"* timestamp, > > * "rawEvent"* text, > > PRIMARY KEY (*"eventName"*,* "eventTime"*) > > ) WITH CLUSTERING ORDER BY (*"eventTime"* ASC); > > > > > > select WRITETIME(*"rawEvent"*),* "eventTime"*,* "rawEvent"* > > from* "eventTable"* > > where* "eventName"* = 'myevent' > > ORDER BY* "eventTime"* DESC; > > > > This returns bunch of events and their writetime, how to get last (or max) > writetime using CQL? > > > > Thanks, > > *Rahul Gupta* > > > ------------------------------ > This e-mail and the information, including any attachments, it contains > are intended to be a confidential communication only to the person or > entity to whom it is addressed and may contain information that is > privileged. If the reader of this message is not the intended recipient, > you are hereby notified that any dissemination, distribution or copying of > this communication is strictly prohibited. If you have received this > communication in error, please immediately notify the sender and destroy > the original message. > > Thank you. > > Please consider the environment before printing this email. >