gpt4 book ai didi

MySql 根据多个条件提供重复计数

转载 作者:行者123 更新时间:2023-11-29 20:46:43 27 4
gpt4 key购买 nike

我有一个表call,其中有两列Customer_Phone_NumberDateTime

我在这里想做的是,对昨天 18:00-10:00PM 之间给我打电话的客户在过去 14 天内重复计数

示例文件 - Sample_Excel_File

请帮忙

最佳答案

Select customer_telephone_number, count(Calls.DateTime) As Count_Calls
From Calls
Where customer_telephone_number In
(
Select customer_telephone_number
From Calls
Where time_to_sec(date_time)
Between time_to_sec(CURRENT_DATE() - INTERVAL 1 DAY) + time_to_sec('10:00:00')
And time_to_sec(CURRENT_DATE() - INTERVAL 1 DAY) + time_to_sec('18:00:00')
) CustPhonedYesterday
And time_to_sec(date_time)
Between time_to_sec(CURRENT_DATE() - INTERVAL 14 DAY) + time_to_sec('00:00:00')
And time_to_sec(CURRENT_DATE() - INTERVAL 1 DAY) + time_to_sec('18:00:00')
Group By Calls.customer_telephone_number;

关于MySql 根据多个条件提供重复计数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38395723/

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