title: Get data from last 30 minutes and get the latest rows
body: <p>I have a table with AIS marine data that gets updated very often.</p>
  
  <p>What I need is the data from the last 30 minutes and from that result the newest rows and MMSI should be unique.</p>
  
  <p>The query I have now:</p>
  
  <pre><code>select max(timestamp) as timestamp, mmsi, navstatus, rot, sog, lon, lat, cog,
  thead, man, mtype from ais_cnb
  where (timestamp &gt; (now() - interval 30 minute))
  group by mmsi
  order by timestamp desc
  </code></pre>
  
  <p>It seems like all the data except the timestamp is old.</p>