我尝试使用 MAX 函数解决这个问题,但得到了结果。有没有办法通过使用任何其他功能来解决它​​?

I tried solving this problem by using MAX function but get the result . Is there a way to solve it by using any other function?

我需要为每个订单获取“第二个 updated_time”,并按“update_time”对它们进行排序。我写了以下查询,它没有给出任何输出。

假设,如果我们在 update_time 上对 table 进行排序(同样的问题,但是扩展) 服务器是 Mysql。将应用 TIMEDIFF() 函数,但如何应用?它正在尝试:

select order_history.,order_history.TIMEDIFF( 来自 (select order_history., row_number() OVER(按 order_id 分区,按 update_time 排序)作为 seqnum 来自 order_history ) order_history 其中序号 = 2 按 update_time;

排序

select update_time

排序

[附图显示orders_history(table为问题)]

I need to get "second updated_time" for each order and sorting them by "update_time".

这听起来像:

select oh.*
from (select oh.*,
             row_number() over (partition by order_id order by update_toime) as seqnum
      from order_history oh
     ) oh
where seqnum = 2
order by update_time;