To 🔥 celebrate the holiday season, Also check out our NEWLY launched Annual plan (Up to 50% off). Use coupon code THANKSGIVING15 and enjoy additional 15% off all paid plans. Coupon expires at 2020/11/30 .
9. Number of high spend customers by month medium


  • Write a query to count the number of customers who spend more than (>) $20 by month
  • Use EXTRACT(YEAR from ts_field) and EXTRACT(MONTH from ts_field) to get year and month from a timestamp column.
  • The order of your results doesn't matter.

Table: payment

Movie rental payment transactions table

   col_name   | col_type
 payment_id   | integer
 customer_id  | smallint
 staff_id     | smallint
 rental_id    | integer
 amount       | numeric
 payment_ts   | timestamp with time zone


Sample results

year	mon	num_hp_customers
2020	2	158
2020	5	520