Posted by o, Oct. 6, 2024, 6:23 a.m.
# 14: Good and Bad days correct code but different outcome
Hello,
Why won't this produce the expected outcome?
As per worded problem, it's flawless
with a as(SELECT * from rental
where extract(year from rental_ts) = 2020 and extract(month from rental_ts) = 5),
b as (select *, extract(day from rental_ts) as day_num
from a),
c as (select count(rental_id) as total_rentals, day_num
from b
group by day_num),
d as (select sum(
case when total_rentals > 100 then 1 else 0
end) as good_days,
sum(
case when total_rentals <= 100 then 1 else 0
end) as bad_days
from c)
select * from d;