gpt4 book ai didi

sql - 在SQL中获取时间之间的平均时间

转载 作者:行者123 更新时间:2023-11-29 05:45:49 24 4
gpt4 key购买 nike

我真的不知道该怎么做。

说我的 table 看起来像这样:

MESSAGES
- id
- date_posted
- content

如何获得发布之间的平均时间? (发布日期)

最佳答案

SELECT  AVG(period)
FROM (
SELECT TIME_TO_SEC(TIMEDIFF(@date_posted, date_posted)) AS period,
@date_posted := date_posted
FROM (
SELECT @date_posted := NULL
) vars,
messages
ORDER BY
date_posted
) q

关于sql - 在SQL中获取时间之间的平均时间,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2237159/

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