gpt4 book ai didi

mysql - 我怎样才能获得我的技术在此查询中的最后位置?

转载 作者:行者123 更新时间:2023-11-30 00:09:24 26 4
gpt4 key购买 nike

我有 2 个包含数据的表:

enter image description here

enter image description here

Posicion,保存各个Tecnico一段时间的位置。

我尝试使用此查询获取每个 Tecnico 的最后一个 Posicion

Select Longitud, Latitude
From (Select idTecnico as id
From Tecnico), Posicion
Where Posicion.idTecnico = id
Max(updated_at)

此查询必须返回 Posicion 表的第 1 行和第 3 行(idPosicion 1 和 3)

但是不起作用

最佳答案

这应该返回给定示例数据的 1 和 3,但会返回所有 tecnico 的最后位置。

SELECT P.Longitud, P.Latitude, P.idTecnico
FROM Posicion P
INNER JOIN (Select max(Uptade_at) maxUptade_at, IdTechnico from Posicion group by IdTecnico) P2
on P.IDTecnico = P2.P.IdTecnico
and P.Uptade_at = maxUptade_at

关于mysql - 我怎样才能获得我的技术在此查询中的最后位置?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24210858/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com