Posted by Yuanyuan, Feb. 25, 2022, 12:58 p.m.
#14 Why my code is wrong
with amt as (select count(rental_id)as num, date(rental_ts)as dt
from rental
where extract(month from rental_ts) = '5'
group by dt)
SELECT sum(case when num > 100 then 1 else 0 end) as good_days,
sum(case when num <= 100 then 1 else 0 end) as bad_days
from amt
The bad days turn out to 1, but why? I assume it will be 25
from rental
where extract(month from rental_ts) = '5'
group by dt)
SELECT sum(case when num > 100 then 1 else 0 end) as good_days,
sum(case when num <= 100 then 1 else 0 end) as bad_days
from amt
The bad days turn out to 1, but why? I assume it will be 25