Reputation: 317
Hi and sorry if I don't do the question the correct way
I have this query :
SELECT
t4.tar_nombre as nombre_tarea,
t2.rdi_fechacti as fecha_actividad,
t3.rea_hrstarea as horas_trabajadas
FROM
act_usuario t1
INNER JOIN
act_regisdiario t2
ON
(t2.usu_id = t1.usu_id)
INNER JOIN
act_registtarea t3
ON
(t3.rdi_id = t2.rdi_id)
INNER JOIN
act_tarea t4
ON
(t4.tar_id = t3.tar_id)
WHERE
t4.usu_id = 4
GROUP BY
t3.rea_id
ORDER BY
t2.rdi_fechacti
And the query print this :
So, I need when in "fecha_Actividad" exist the same "nombre_actividad" , thats only show me one "fecha_actividad" and the sum of "horas_trabajadas".
For example the query show this:
But I need this (because the same "nombre_tarea" is in the same date):
The reference:
Sorry my english.
Upvotes: 0
Views: 23
Reputation: 9765
You can simply use SUM(field)
syntax after grouping.
SELECT
t4.tar_nombre as nombre_tarea,
t2.rdi_fechacti as fecha_actividad,
t3.rea_hrstarea as horas_trabajadas,
SUM(t3.rea_hrstarea)
FROM
act_usuario t1
INNER JOIN
act_regisdiario t2
ON
(t2.usu_id = t1.usu_id)
INNER JOIN
act_registtarea t3
ON
(t3.rdi_id = t2.rdi_id)
INNER JOIN
act_tarea t4
ON
(t4.tar_id = t3.tar_id)
WHERE
t4.usu_id = 4
GROUP BY
t4.tar_nombre
ORDER BY
t2.rdi_fechacti
There are also other functions you can use on grouped results. You can find them here.
Upvotes: 1