🌱 Creating Histograms in SQL

Source
with bins as (
  select
    floor(actions_count/100.00)*100 as bin_floor,
    count(user_id) as count
  from product_actions
  group by 1
  order by 1
   -- same query as above, just in a CTE
)

select
  bin_floor,
  bin_floor || ' - ' || (bin_floor + 100) as bin_range,
  count
from bins
order by 1;
Made by Brandon . If you find this project useful you can donate.