我需要在我的表格位置返回每个设备的最后一行
我的表名是:位置
+------------+----------+--------------+--------------+----------+
| locationId | deviceId | dataRegistro | horaRegistro | location |
+------------+----------+--------------+--------------+----------+
| 50 | 1 | 2012-11-07 | 15:35:00 | A12 |
+------------+----------+--------------+--------------+----------+
| 51 | 1 | 2012-11-07 | 15:37:40 | B2 |
+------------+----------+--------------+--------------+----------+
| 52 | 2 | 2012-11-07 | 15:35:12 | B8 |
+------------+----------+--------------+--------------+----------+
| 53 | 2 | 2012-11-07 | 15:35:40 | 50C |
+------------+----------+--------------+--------------+----------+
| 54 | 2 | 2012-11-07 | 15:40:00 | 94A |
+------------+----------+--------------+--------------+----------+
从我做的一个设备中选择最后一行
select L from Location L where deviceId = :deviceId order by "dataRegistro" DESC, "horaRegistro" DESC limit 1
现在如何选择每台设备的所有最新位置?:( 我使用 Java JPA。
谢谢,
埃万德罗