-1
I have the following select, in it I bring the point of operation on day 1, and the subquery brings the point of dia2.
SELECT id_Ponto,
(SELECT id_Ponto
FROM ponto
WHERE cancelado = false
AND fr_Funcionario = 4
AND MONTH(data) = '08'
AND YEAR(data) = '2021'
AND DAY(data) = '02') as id_Ponto1
FROM ponto
WHERE cancelado = false
AND fr_Funcionario = 4
AND MONTH(data) = '08'
AND YEAR(data) = '2021'
AND DAY(data) = '01'
However, if the select of day 1 does not exist in the table and 2 does not exist, the select will not be displayed, only the select of day 2 will be displayed on the screen when the one of day 1 exists. Is there any way to always bring something in select?
Try "window-Function" LAG and LEAD , do this automatically. https://dev.mysql.com/doc/refman/8.0/en/window-function-descriptions.html
– Motta