我有一个相同的实时和开发数据库。
对每个数据库执行以下 SELECT 语句时,我得到不同的结果。
SELECT CASE WHEN (TIME_TO_SEC(c.duration) BETWEEN 0 AND 30) THEN '00:00:00 - 00:00:30'
WHEN (TIME_TO_SEC(c.duration) BETWEEN 31 AND 60) THEN '00:00:31 - 00:01:00'
WHEN (TIME_TO_SEC(c.duration) BETWEEN 61 AND 90) THEN '00:01:01 - 00:01:30'
WHEN (TIME_TO_SEC(c.duration) BETWEEN 91 AND 120) THEN '00:01:31 - 00:02:00'
WHEN (TIME_TO_SEC(c.duration) BETWEEN 121 AND 180) THEN '00:02:01 - 00:03:00'
WHEN (TIME_TO_SEC(c.duration) BETWEEN 181 AND 240) THEN '00:03:01 - 00:04:00'
WHEN (TIME_TO_SEC(c.duration) BETWEEN 241 AND 300) THEN '00:04:01 - 00:05:00'
WHEN (TIME_TO_SEC(c.duration) BETWEEN 301 AND 420) THEN '00:05:01 - 00:07:00'
WHEN (TIME_TO_SEC(c.duration) BETWEEN 421 AND 600) THEN '00:07:01 - 00:10:00'
ELSE 'Over 00:10:00'
END AS 'time_period',
COUNT(c.id) AS 'call_usage',
SEC_TO_TIME(SUM(TIME_TO_SEC(c.duration))) AS 'total_duration',
SUM(TIME_TO_SEC(c.duration)) / TIME_TO_SEC('838:59:59') AS 'percent_total'
FROM call_detail c
INNER JOIN credit_unions cu ON c.credit_union_id = cu.id
WHERE cu.abbreviation = 'REMOVED_FOR_SECURITY'
AND c.call_date BETWEEN '2013-01-01' AND DATE_ADD('2013-01-31', INTERVAL 1 DAY)
GROUP BY 'time_period'
ORDER BY 'time_period' ASC
实时数据库给了我以下结果,这是正确的结果。
time_period call_usage total_duration percent_total
"00:00:00 - 00:00:30" 12033 83:01:42 0.0990
"00:00:31 - 00:01:00" 22947 291:34:48 0.3475
"00:01:01 - 00:01:30" 11137 236:53:24 0.2823
"00:01:31 - 00:02:00" 5904 175:13:54 0.2089
"00:02:01 - 00:03:00" 5970 247:05:24 0.2945
"00:03:01 - 00:04:00" 2591 150:58:54 0.1800
"00:04:01 - 00:05:00" 1359 101:49:24 0.1214
"00:05:01 - 00:07:00" 1197 116:25:36 0.1388
"00:07:01 - 00:10:00" 481 65:48:24 0.0784
"Over 00:10:00" 192 42:22:24 0.0505
开发数据库给了我以下结果,这是不正确的。
time_period call_usage total_duration percent_total
"00:00:31 - 00:01:00" 63811 858:59:59 1.8012
我无法弄清楚为什么/如何发生这种情况。