There is a messages table in my postgreSql DB. The table has names: deviceId, timestamp, message. deviceId is identical, it indicates the id of existing device.
deviceId timestamp message
dev12345 2020-01-02 21:01:02 hello Jack
dev12229 2020-01-02 12:03:02 good
dev22245 2020-01-01 12:01:05 hello Mary
dev12345 2020-01-01 11:03:02 good morning
... ... ...
Assume there are total 100 devices, each device has send many messages at different time. I want to select the last messages send by some devices. For example, the last messages send by dev12345
and dev22245
: hello Jack
and hello Mary
Can you tell me how to do that using postgreSql command?
Thanks