In the Caffé solution, we only needed to include a clause in where data is null:
select
user.id, user.nome, ponto.data, ponto.entrada01,
ponto.saida01, ponto.entrada02, ponto.saida02
(case when ponto.data is not null then 'sim' else 'não') as bateu_ponto
from user left join ponto on ponto.usuarioId = user.id
where (data is null or (data between data1 and data2))
group by user.id, user.nome, ponto.data, ponto.entrada01,
ponto.saida01, ponto.entrada02, ponto.saida02, bateu_ponto
Users who did not hit the dot do not have the date, so you should also consider the date to be null or in the range that you tell point users.
================ Correct solution =================================== p>
The above solution does not answer. If the user has a date point different from the one in the where, that is, it does not meet the where clauses since it is not null and is different from the filter date.
The correct solution was to create a sub query only with the points of the day that you want to consult, with this table I made a left join with user, now all users are being returned even if there are points for other dates. Here is the new query:
select user.id, user.name, ponto.dataPonto,
ponto.entrada01, ponto.saida01,
ponto.entrada02, ponto.saida02,
case when (ponto.dataPonto is not null) then 'sim' else 'não' end as bateu_ponto
from user left join
(select *
from pontospordia p
where p.dataPonto between '2016-05-07' and '2016-05-10 23:59:59') ponto on ponto.usuarioId = user.id
group by user.id,
user.name,
ponto.dataPonto,
ponto.entrada01,
ponto.saida01,
ponto.entrada02,
ponto.saida02
I hope I have helped.