MySQL Forums
Forum List  »  General

Re: bug (5.6.22) in ADDTIME?
Posted by: Peter Brawley
Date: January 23, 2015 05:48PM

You're determined to prove the mistake is MySQL's, not yours? Not useful. The Select clause in your new query ...

SELECT a.codasig_cita, ADDTIME(a.hora_cita, SEC_TO_TIME(SUM(TIME_TO_SEC(pe.duracion))) ) AS "add (wrong)"
FROM asig_cita2 a, citas_proc_empl2 cpe, proc_empl2 pe
WHERE cpe.codproc_empl=pe.codproc_empl AND a.codasig_cita=cpe.codasig_cita
GROUP BY a.codasig_cita;

... refers to a non-aggregated column a.hora_cita that's missing from your Group By clause. Correcting that error yields the result you expect ...

SELECT a.codasig_cita, ADDTIME(a.hora_cita, SEC_TO_TIME(SUM(TIME_TO_SEC(pe.duracion))) ) AS "add (wrong)"
FROM asig_cita2 a, citas_proc_empl2 cpe, proc_empl2 pe
WHERE cpe.codproc_empl=pe.codproc_empl AND a.codasig_cita=cpe.codasig_cita
 GROUP BY a.codasig_cita, a.hora_cita;
+--------------+-------------+
| codasig_cita | add (wrong) |
+--------------+-------------+
|       741550 | 07:00:00    |
|       742135 | 07:45:00    |
|       742413 | 08:15:00    |
|       742460 | 08:00:00    |
+--------------+-------------+

Options: ReplyQuote


Subject
Written By
Posted
January 23, 2015 10:46AM
January 23, 2015 12:56PM
Re: bug (5.6.22) in ADDTIME?
January 23, 2015 05:48PM
January 26, 2015 12:51PM
January 26, 2015 03:02PM
January 23, 2015 05:55PM
January 26, 2015 03:17PM
January 26, 2015 03:54PM
January 26, 2015 06:35PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.