mardi 24 novembre 2015

query most recent

I need a help here - write your code in SQLite 3.8.6

SELECT sensor_id
      ,event_type
      ,VALUE
FROM   events
       JOIN (
                SELECT sensor_id
                      ,event_type
                      ,VALUE
                      ,MAX(TIME) AS maxTime
                FROM   events
                GROUP BY
                       sensor_id
                      ,event_type
            )table1
            ON  events.sensor_id = table1.sensor_id
                AND events.Time = t.maxTime
ORDER BY
       events.time DESC

Aucun commentaire:

Enregistrer un commentaire