My database have a device reading list,
columns are id ,device_id ,device_reading ,update_time
How can I select all latest reading for each device?
that means,I need sort data according to update_time first
then I need to filter database use some unique method(unique device_id)
then the I can retrieve device_reading from rows filtered just now.
That is to say, retrieve column a from table where b is distinct
how can I achieve this? in ruby on rails
thanks in advance