Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/229.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/59.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php MySQL-在找不到结果的基于时间的查询中添加零_Php_Mysql_Time_Gaps And Islands - Fatal编程技术网

Php MySQL-在找不到结果的基于时间的查询中添加零

Php MySQL-在找不到结果的基于时间的查询中添加零,php,mysql,time,gaps-and-islands,Php,Mysql,Time,Gaps And Islands,我有一个打印时间和平均值的查询。唯一的问题是-如果在我运行这个程序的6周时间内什么都没发生-它会跳过它。。。我需要15分钟的时间,在它的位置上有一个空或零。我的问题是: $staffing_qry = "SELECT MAKETIME(hour(opened_dt),floor(minute(opened_dt)/15)*15,0) AS time, "; $staffing_qry .= "ROUND(COUNT(*)/COUNT(DISTINCT DATE(opened_dt)),1) AS

我有一个打印时间和平均值的查询。唯一的问题是-如果在我运行这个程序的6周时间内什么都没发生-它会跳过它。。。我需要15分钟的时间,在它的位置上有一个空或零。我的问题是:

$staffing_qry = "SELECT MAKETIME(hour(opened_dt),floor(minute(opened_dt)/15)*15,0) AS time, ";
$staffing_qry .= "ROUND(COUNT(*)/COUNT(DISTINCT DATE(opened_dt)),1) AS calls, ";
$staffing_qry .= "ROUND(AVG(work_time)/60,1) AS work, ";
$staffing_qry .= "ROUND(AVG(tele_time)/60,1) AS tele, ";
$staffing_qry .= "ROUND(AVG(comm_time)/60,1) AS comm, ";
$staffing_qry .= "ROUND(IFNULL(COUNT(*)/COUNT(DISTINCT DATE(opened_dt)),0)/3,1) AS techs ";
$staffing_qry .= "FROM detail_head ";
$staffing_qry .= "LEFT JOIN detail_detail ON detail_detail.detail_head_uid = detail_head.detail_head_uid ";
$staffing_qry .= "WHERE dayname(opened_dt) = $dow_option $staffing_option $proactive_option $incoming_option ";
$staffing_qry .= "AND (DATE(opened_dt) >= (CURDATE() - INTERVAL 42 DAY))";
$staffing_qry .= "GROUP BY (hour(opened_dt)*100)+floor(minute(opened_dt)/15) ";
建议

已解决:

if(isset($_REQUEST['date_range'])) {
        $date_range_option = (integer) $_REQUEST['date_range'];
}

对于这类问题,有一整段堆栈溢出。它被称为“缺口和岛屿”。我在你的问题上加了一个标签,以吸引更多的听众。请看这里:好的-我可以看出这个问题是如何归入那个类别的。。。非常感谢。你有解决我具体问题的办法吗?其中许多是特定于给定查询的。抱歉,我没有。我只知道在哪里分类。只是浏览了一下,但这应该可以: