0

i have a prinscreen of the problem
http://i.imgur.com/GMJho9r.jpg
i use mySQL to create the query and i have a database called tap that contains the events table

I try

SELECT sensor_id,event_type,value
from tap.events
where events.time = (SELECT MAX(events.time) from tap.events)
group by sensor_id,event_type
ORDER BY sensor_id,event_type;

I get only the 2,2,2 line , nothing else, can anyone help me ... what is the right query?

Edited by pritaeas: Added markdown.

2
Contributors
2
Replies
18
Views
3 Years
Discussion Span
Last Post by urtrivedi
0

I also tried

SELECT sensor_id,event_type,value,MAX(events.time)
from tap.events
group by sensor_id,event_type
ORDER BY sensor_id,event_type;

and I get 4 rows but the first is 2,2,5 which is not right.

Edited by pritaeas: Added markdown.

0
SELECT events.sensor_id, events.event_type, events.value
from events 
inner join (select sensor_id, event_type, max(time) maxtime 
            from tap.events group by sensor_id, event_time) t on 
            t.sensor_id=events.sensor_id and t.event_type=events.event_type and t.maxtime=events.time
ORDER BY events.sensor_id,events.event_type;

Edited by urtrivedi

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.