获取Laravel中选定查询的平均日期 [英] Get average date in a selected query in Laravel
本文介绍了获取Laravel中选定查询的平均日期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是否可以计算用户在查询中的平均时间?
Is it possible to compute the average time of a user in a query?
赞:
reportedDate userID
------------ ------
2018-03-17 00:27:15 1
2018-03-17 00:32:28 1
推荐答案
类似
SELECT
`user_id`,
DATE_FORMAT(FROM_UNIXTIME(AVG(UNIX_TIMESTAMP(`reportedDate `))), '%e %b %Y') as `averageReportedDate`
FROM `users`
GROUP BY `user_id`
应该工作.
这篇关于获取Laravel中选定查询的平均日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文