0
Voici ma Mysql requêteDans Mysql requête DATE_SUB ne pas retourner résultat attendu
SELECT COUNT(*) CallCnt,ANBCnt, t2.Duration,(ANB) Number,
((DATE_SUB('2012-12-10 05:22:30',
INTERVAL (SELECT CONCAT(''',t2.Duration:0,''')) MINUTE_SECOND))) Mintime,
('2012-12-10 05:22:30') Maxtime,
(1) TYPE,
(t1.CallTypeId)
FROM cdr_temp1_check t1
INNER JOIN cdr_temp1_check_details t2
ON t1.CallTypeId=t2.CallTypeId
WHERE TimeStamp1 >= DATE_SUB('2012-12-10 05:22:30',
INTERVAL (SELECT CONCAT(''',t2.Duration:0,''')) MINUTE_SECOND)
AND TimeStamp1<='2012-12-10 05:22:30'
GROUP BY ANB
HAVING COUNT(*) > ANBCnt
résultat retourné est
CallCnt ANBCnt Duration Number Mintime Maxtime TYPE CallTypeId
------- ------ -------- ---------- ------------------- ------------------- ------ ----------
267 40 25 2042011234 2012-12-10 05:20:30 2012-12-10 05:22:30 1 5
134 20 15 9895697970 2012-12-10 05:20:30 2012-12-10 05:22:30 1 3
Résultat attendu
CallCnt ANBCnt Duration Number Mintime Maxtime TYPE CallTypeId
------- ------ -------- ---------- ------------------- ------------------- ------ ----------
267 40 25 2042011234 2012-12-10 04:57:30 2012-12-10 05:22:30 1 5
134 20 15 9895697970 2012-12-10 04:57:30 2012-12-10 05:22:30 1 3
Colonne question montrant est la mintime qui devrait être Maxtime minus Duration
dat a travaillé tnks – iJade