Answered by joshuadavis

with bins as (
  select
    floor(networth/10.00)*10 as bin_floor,
    count(name) as count
  from billionaires_2021
  group by 1
  order by 1
)
select
  bin_floor,
  concat(bin_floor, '-', (bin_floor + 10)) as bin_range,
  count
from bins
order by 1 desc;

Answered by anonymousUser

with bins as (
  select
    floor(networth/10.00)*10 as bin_floor,
    count(name) as count
  from billionaires_2021
  group by 1
  order by 1
)
select
  bin_floor,
  concat(bin_floor, '-', (bin_floor + 10)) as bin_range,
  count
from bins
order by 1 desc;