I'm running a query
that needs to get the first 5 lines with limit 5
. However, there are times when they will return less than 5 lines. The value is empty, neither NULL
, nor 0
.
I try to make a case when
, but it keeps returning empty. Does anyone know how I can resolve this?
My query
is below:
select case when defail5 then 0 else defail5 end
from (select failure, count(failure) as defail5
from reparo.falhas_consolidadas
where brand2 in ('LBG_DKT')
and week = 'week-5-16'
group by failure
order by count(failure) desc limit 4 offset 3) as tb1;