title: getting latest inserted object from riak timeseries
body: <p>Procedure to get latest record from <code>Riak TS</code> based on timestamp.</p>
  
  <p>I created following table:</p>
  
  <pre><code>CREATE TABLE devicedetail (memberId SINT64 NOT NULL, type VARCHAR NOT NULL,model VARCHAR NOT NULL,imei VARCHAR NOT NULL,deviceId VARCHAR NOT NULL,manufacturer VARCHAR NOT NULL,os VARCHAR NOT NULL,version VARCHAR NOT NULL,time TIMESTAMP NOT NULL,PRIMARY KEY ((memberId),memberId));
  </code></pre>
  
  <p>Insert data using SQL:</p>
  
  <pre><code>INSERT INTO devicedetail VALUES (110,'health Kit','andorid-4.0','76565657675222','sdgsd1212','sony','windows','5.0',1420113600000);
  </code></pre>
  
  <p>and now I want to select <code>deviceId</code> based on latest inserted record:</p>
  
  <pre><code>select deviceId from devicedetail where memberId=110 and type='health Kit' order by time desc limit 1;
  </code></pre>
  
  <p>I am getting <em>Exception</em> like:</p>
  
  <blockquote>
    <p><strong>SQL Parser error {&lt;&lt;"order">>,riak_ql_parser,
                      ["syntax error before: ","identifier"]}</strong></p>
  </blockquote>
  
  <p>but while querying:</p>
  
  <pre><code>select deviceId from devicedetail where memberId=110 and type='health Kit';
  </code></pre>
  
  <p><strong>Getting Output as:</strong></p>
  
  <pre><code>+---------+   
  |deviceId |
  +---------+
  |sdgsd1212|
  +---------+
  </code></pre>
  
  <p>Anyone knows how we get this in a simple way? Please tell me.</p>