I have the following tables:
REPORTEBETEITIVA
_______________________________________________________
| idReporteBeteitiva | HorasTrabajo |Trabajador |
-------------------------------------------------------
| 1 | 8 | 1 |
-------------------------------------------------------
| 2 | 8 | 1 |
-------------------------------------------------------
| 3 | 14 | 2 |
-------------------------------------------------------
TRABAJADOR
________________________________________
| idTrabajador | Nombre | Cedula |
----------------------------------------
| 1 | PEDRO | 1054632 |
----------------------------------------
| 2 | CAMILO | 1234555 |
----------------------------------------
What I want is that at the time of making the query, I add the total number of hours under each record per user, so:
______________________
| Nombre | HorasT |
----------------------
| Pedro | 16 |
----------------------
| TOTAL | 16 |
----------------------
| Camilo | 12 |
----------------------
| TOTAL | 12 |
-----------------------------
|TOTAL | 28 |
-----------------------------
What I want is to show me the individual result, only I have achieved the following:
______________________
| Nombre | HorasT |
----------------------
| Pedro | 16 |
----------------------
| Camilo | 12 |
-----------------------------
|TOTAL | 28 |
-----------------------------
My query:
SELECT trabajador.Nombre, sum(HorasTrabajo) as HorasT FROM
reportebeteitiva INNER JOIN trabajador ON reportebeteitiva.Trabajador =
trabajador.idTrabajador group by trabajador.Cedula;
Thanks for the help !!!