43. Customers who rented vs. those who did not medium


Instruction

  • Write a query to return the number of customers who rented at least one movie vs. those who didn't in May 2020.
  • The order of your results doesn't matter.
  • Use customer table as the base table for all customers (assuming all customers have signed up before May 2020)
  • Rented: if a customer rented at least one movie.
  • Bonus: Develop a LEFT JOIN as well as a RIGHT JOIN solution

Table 1: customer


  col_name   | col_type
-------------+--------------------------
 customer_id | integer
 store_id    | smallint
 first_name  | text
 last_name   | text
 email       | text
 address_id  | smallint
 activebool  | boolean
 create_date | date
 active      | integer

Table 2: rental


   col_name   | col_type
--------------+--------------------------
 rental_id    | integer
 rental_ts    | timestamp with time zone
 inventory_id | integer
 customer_id  | smallint
 return_ts    | timestamp with time zone
 staff_id     | smallint

Sample results

   hass_rented | count
-----------+-------
 rented      |   123
 never-rented  |   456