gpt4 book ai didi

mysql - 如何从mysql数据库中获取每小时的数据

转载 作者:行者123 更新时间:2023-11-30 01:22:53 25 4
gpt4 key购买 nike

我必须根据日期时间每小时从数据库获取数据,我尝试过但无法得到这个想法..我是 SQL 新手,你能帮助我吗?我正在尝试获取特定用户在一小时内执行了多少操作的数据

select username,count(message) as '8-9',count(message) as '9-10',count(message) as '10-11'
from customer_1.audit_trail
inner join inteliviz.user on customer_1.audit_trail.user_id = inteliviz.users.id
where datetime>'2013-08-21 08:00:00' and datetime<'2013-08-21 09:00:00'
group by username limit 1000;

最佳答案

在之间使用

select username,count(message) as '8-9',count(message) as '9-10',count(message) as '10-11'
from customer_1.audit_trail
inner join inteliviz.user on customer_1.audit_trail.user_id = inteliviz.users.id
where datetime between '2013-08-21 08:00:00' and '2013-08-21 09:00:00'
group by username limit 1000;

关于mysql - 如何从mysql数据库中获取每小时的数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18354316/

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