0
I have two tables with the following data:
I want to rescue from the database all users and the amount of jobs they have performed. I was using the following SQL:
SELECT u.usuario, COUNT(t.id) AS '4'
FROM usuario u LEFT JOIN trabalho t
ON u.usuario = t.idUsuario
WHERE t.realizado = 1
AND t.dataTermino <= '2018-05-01'
AND t.dataTermino >= '2018-04-01'
GROUP BY u.usuario
The problem is that if there is no work done for a user, the line is not returned, and I want to return the user name and 0
.
The closure is similar, but I believe your case the "WHERE t.realizado = 1" only hinders, no?
– Bacco
Closed question, but follow mine solution
– Lacobus
https://forum.imasters.com.br/topic/467840-resolver%C2%A0select-com-group-by-same-no-record-correspondent/? do=findComment&comment=1855090 see if it helps
– Motta