0

それぞれ6列を持つ4つのクエリがあります。WHERE 句がそれぞれの場合でわずかに異なることを除いて、各クエリは同じです。私が見たいのは、比較のために隣り合った各列の各クエリ結果です。

結果テーブル ヘッダーの例: time(1 つだけ)、calls1、calls2、calls3、calls4、work1、work2、work3、work4、tele1、tele2、tele3、tele4、comm1、comm2、comm3、comm4、techs1、techs2、techs3、techs4 .

実際のクエリは次のとおりです。比較クエリを作成するのを手伝ってください。T

SELECT CONCAT(hour(opened_dt),':',floor(minute(opened_dt)/15)*15) AS time, COUNT(*)/COUNT(DISTINCT DATE(opened_dt)) AS r_calls, ROUND(AVG(work_time),2)/60 AS r_work, ROUND(AVG(tele_time),2)/60 AS r_tele, ROUND(AVG(comm_time),2)/60 AS r_comm, IFNULL(COUNT(*)/COUNT(DISTINCT DATE(opened_dt)),0)/3 AS r_techs 
FROM detail_head LEFT JOIN detail_detail ON detail_detail.detail_head_uid = detail_head.detail_head_uid 
WHERE call_origins_uid != 5 
AND DATE(opened_dt) >= (CURDATE() - INTERVAL 42 DAY) 
AND dayname(opened_dt) = 'SUNDAY' 
GROUP BY (hour(opened_dt)*100)+floor(minute(opened_dt)/15) 


SELECT CONCAT(hour(opened_dt),':',floor(minute(opened_dt)/15)*15) AS time, COUNT(*)/COUNT(DISTINCT DATE(opened_dt)) AS calls, ROUND(AVG(work_time),2)/60 AS work, ROUND(AVG(tele_time),2)/60 AS tele, ROUND(AVG(comm_time),2)/60 AS comm, IFNULL(COUNT(*)/COUNT(DISTINCT DATE(opened_dt)),0)/3 AS techs 
FROM detail_head LEFT JOIN detail_detail ON detail_detail.detail_head_uid = detail_head.detail_head_uid 
WHERE call_origins_uid != 5 
AND DATE(opened_dt) >= (CURDATE() - INTERVAL 42 DAY) 
AND dayname(opened_dt) = 'SUNDAY' 
AND call_origins_uid = 1 
GROUP BY (hour(opened_dt)*100)+floor(minute(opened_dt)/15)


SELECT CONCAT(hour(opened_dt),':',floor(minute(opened_dt)/15)*15) AS time, COUNT(*)/COUNT(DISTINCT DATE(opened_dt)) AS calls, ROUND(AVG(work_time),2)/60 AS work, ROUND(AVG(tele_time),2)/60 AS tele, ROUND(AVG(comm_time),2)/60 AS comm, IFNULL(COUNT(*)/COUNT(DISTINCT DATE(opened_dt)),0)/3 AS techs 
FROM detail_head LEFT JOIN detail_detail ON detail_detail.detail_head_uid = detail_head.detail_head_uid 
WHERE call_origins_uid != 5 
AND DATE(opened_dt) >= (CURDATE() - INTERVAL 42 DAY) 
AND dayname(opened_dt) = 'SUNDAY' 
AND call_origins_uid = 4 
GROUP BY (hour(opened_dt)*100)+floor(minute(opened_dt)/15)


SELECT CONCAT(hour(opened_dt),':',floor(minute(opened_dt)/15)*15) AS time, COUNT(*)/COUNT(DISTINCT DATE(opened_dt)) AS calls, ROUND(AVG(work_time),2)/60 AS work, ROUND(AVG(tele_time),2)/60 AS tele, ROUND(AVG(comm_time),2)/60 AS comm, IFNULL(COUNT(*)/COUNT(DISTINCT DATE(opened_dt)),0)/3 AS techs 
FROM detail_head LEFT JOIN detail_detail ON detail_detail.detail_head_uid = detail_head.detail_head_uid 
WHERE DATE(opened_dt) >= (CURDATE() - INTERVAL 42 DAY) 
AND dayname(opened_dt) = 'SUNDAY' 
GROUP BY (hour(opened_dt)*100)+floor(minute(opened_dt)/15)
4

1 に答える 1

1

各テーブルに「CREATE TEMPORARY TABLE TableName1」を使用し、クエリを記述して列を並べ替え、完了したらテーブルを削除できます。

于 2013-06-18T17:35:20.977 に答える