gpt4 book ai didi

sql - 按半小时间隔计算调用次数

转载 作者:行者123 更新时间:2023-12-04 12:46:48 24 4
gpt4 key购买 nike

我试图获取每半小时间隔的调用次数。想不通。

select 
count(call_id) as '#Calls',
1/2 h(date_time) as 'Call_Interval'
from My_Table

enter image description here

最佳答案

一种按不同时间间隔聚合的方法是使用 DATEADDDATEDIFF:

SELECT 
COUNT(*) as '#Calls',
DATEADD(minute, (DATEDIFF(minute, '', date_time) / 30) * 30, '') as Call_Interval
FROM dbo.My_Table
GROUP BY DATEADD(minute, (DATEDIFF(minute, '', date_time) / 30) * 30, '')
ORDER BY Call_Interval;

关于sql - 按半小时间隔计算调用次数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44567163/

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