我有四個查詢,每個查詢有6列。除WHERE子句在每種情況下略有不同外,每個查詢都是相同的。我希望看到的是eachother旁邊的每個列的每個查詢結果進行比較。示例結果表頭:time(only one),calls1,calls2,calls3,calls4,work1,work2,work3,work4,tele1,tele2,tele3,tele4,comm1,comm2,comm3,comm4,techs1,techs2 ,techs3,techs4。加入四個具有相同列,不同條件的MySQL查詢
實際查詢如下。請幫我做一個比較性的查詢。牛逼
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)
您需要格式化您的查詢,以便有人爲您提供幫助。這是非常重要的眼睛:/ – user962449
更新了查詢,使他們更容易閱讀。對於那個很抱歉! – brandoncluff