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?

Recommended Answers

All 2 Replies

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.

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;
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.