Posted by kavita, May 29, 2022, 8:03 a.m.
43. Customers who rented vs. those who did not - Question related to solution
Hi,
Your solution has different query , doing the below query is right
select
hass_rented,count(*)
from (
SELECT distinct c.customer_id,
case when r.rental_id is not null then 'rented'
when r.rental_id is null then 'never-rented' end as hass_rented
FROM customer as c
left join rental as r
on c.customer_id =r.customer_id
and extract(month from r.rental_ts)=5
and extract(year from r.rental_ts)=2020)final
group by hass_rented