문제
SQLite
내가 작성한 정답
select s.station_id, s.name, s.local, round((c19*100.0/c18*1.0),2)usage_pct
from (select rent_station_id,
sum(case strftime('%Y%m',rent_at) when '201810' then 1 else 0 end) c18,
sum(case strftime('%Y%m',rent_at) when '201910' then 1 else 0 end) c19
from rental_history
group by rent_station_id
having c18*1.0/c19*1.0 <=0.5) c
join station s on s.station_id = c.rent_station_id
where c.c18 >0 and c.c19 > 0; Share article