我有一个打印出时间和平均值的查询。唯一的问题是 - 如果在我运行它的 6 周内没有发生任何事情 - 它会直接跳过它......我需要 15 分钟的时间段在其位置上放置一个 NULL 或零。这是我的查询:
$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) ";
建议?