I need to make a select with a case, if the condition is true I need to use a counter that will be a new column, otherwise the counter will be displayed without any changes, but I'm not able to do it, I tried the ROW_NUMBER function but it did not work , if someone can help me I thank:
declare @c int
set @c = 0
select
(
case when HR_ENTRADA > is null then
(
(ROW_NUMBER()over(order by HR_ENTRADA asc)+@c)
)
else
(
@c
)
end
)as FALTAS
from TB_REGISTRO_PONTO
This query works, but if it falls into the else, this row_number counter adds tmb, and I do not want it, I just want it to add if the condition is true.