0
Personal someone can help me with a select case problem, I need to make a select of an expression and if that expression gives a negative result, it shows me the value, if positive the value has to be changed to zero, but I’m not getting it wrong when changing the value to zero, and my alias to name table tmb does not work, follow the query below:
select case
when DATEDIFF(MINUTE,HR_ENTRADA,HR_SAIDA) - DATEDIFF(MINUTE,HR_SAIDA_ALMOCO,HR_ENTRADA_ALMOCO ) < 0
then (select DATEDIFF(MINUTE,HR_ENTRADA,HR_SAIDA) - DATEDIFF(MINUTE,HR_SAIDA_ALMOCO,HR_ENTRADA_ALMOCO ) as saldo)
else
set saldo = 0
end
from TB_REGISTRO_PONTO
Opa got it right, that’s what I was wrong I got it right here, thank you very much!!
– Rodrigo Lima dos Santos