Answered by satish.s

select B.country
    from
		(
        select A.country, A.bin_range, count(*) as cnt
        from 
              (
              select country,
                  case
                  when networth < 10 then '0-10'
                  when networth < 20 then '10-20'
                  when networth < 30 then '20-30'
                  when networth < 40 then '30-40'
                  when networth < 50 then '40-50'
                  when networth < 60 then '50-60'
                  when networth < 70 then '60-70'
                  when networth < 80 then '70-80'
                  when networth < 90 then '80-90'
                  when networth < 100 then '90-100'
                  when networth < 110 then '100-110'
                  when networth < 120 then '110-120'
                  when networth < 130 then '120-130'
                  when networth < 140 then '130-140'
                  when networth < 150 then '140-150'
                  when networth < 160 then '150-160'
                  when networth < 170 then '160-170'
                  when networth < 180 then '170-180'
                  when networth < 190 then '180-190'
                  when networth < 200 then '190-200'
                  end as bin_range
              from billionaires_2021
              ) as A
        group by A.country, A.bin_range
        order by A.country asc, A.bin_range asc
        ) as B
 	group by B.country
    order by B.country;

Answered by wlldodsn

select B.country
    from
		(
        select A.country, A.bin_range, count(*) as cnt
        from 
              (
              select country,
                  case
                  when networth < 10 then '0-10'
                  when networth < 20 then '10-20'
                  when networth < 30 then '20-30'
                  when networth < 40 then '30-40'
                  when networth < 50 then '40-50'
                  when networth < 60 then '50-60'
                  when networth < 70 then '60-70'
                  when networth < 80 then '70-80'
                  when networth < 90 then '80-90'
                  when networth < 100 then '90-100'
                  when networth < 110 then '100-110'
                  when networth < 120 then '110-120'
                  when networth < 130 then '120-130'
                  when networth < 140 then '130-140'
                  when networth < 150 then '140-150'
                  when networth < 160 then '150-160'
                  when networth < 170 then '160-170'
                  when networth < 180 then '170-180'
                  when networth < 190 then '180-190'
                  when networth < 200 then '190-200'
                  end as bin_range
              from billionaires_2021
              ) as A
        group by A.country, A.bin_range
        order by A.country asc, A.bin_range asc
        ) as B
 	group by B.country
    order by B.country;

Answered by ran428

select B.country
    from
		(
        select A.country, A.bin_range, count(*) as cnt
        from 
              (
              select country,
                  case
                  when networth < 10 then '0-10'
                  when networth < 20 then '10-20'
                  when networth < 30 then '20-30'
                  when networth < 40 then '30-40'
                  when networth < 50 then '40-50'
                  when networth < 60 then '50-60'
                  when networth < 70 then '60-70'
                  when networth < 80 then '70-80'
                  when networth < 90 then '80-90'
                  when networth < 100 then '90-100'
                  when networth < 110 then '100-110'
                  when networth < 120 then '110-120'
                  when networth < 130 then '120-130'
                  when networth < 140 then '130-140'
                  when networth < 150 then '140-150'
                  when networth < 160 then '150-160'
                  when networth < 170 then '160-170'
                  when networth < 180 then '170-180'
                  when networth < 190 then '180-190'
                  when networth < 200 then '190-200'
                  end as bin_range
              from billionaires_2021
              ) as A
        group by A.country, A.bin_range
        order by A.country asc, A.bin_range asc
        ) as B
 	group by B.country
    order by B.country;

Answered by trabi71

select B.country
    from
		(
        select A.country, A.bin_range, count(*) as cnt
        from 
              (
              select country,
                  case
                  when networth < 10 then '0-10'
                  when networth < 20 then '10-20'
                  when networth < 30 then '20-30'
                  when networth < 40 then '30-40'
                  when networth < 50 then '40-50'
                  when networth < 60 then '50-60'
                  when networth < 70 then '60-70'
                  when networth < 80 then '70-80'
                  when networth < 90 then '80-90'
                  when networth < 100 then '90-100'
                  when networth < 110 then '100-110'
                  when networth < 120 then '110-120'
                  when networth < 130 then '120-130'
                  when networth < 140 then '130-140'
                  when networth < 150 then '140-150'
                  when networth < 160 then '150-160'
                  when networth < 170 then '160-170'
                  when networth < 180 then '170-180'
                  when networth < 190 then '180-190'
                  when networth < 200 then '190-200'
                  end as bin_range
              from billionaires_2021
              ) as A
        group by A.country, A.bin_range
        order by A.country asc, A.bin_range asc
        ) as B
 	group by B.country
    order by B.country;

Answered by anonymousUser

select B.country
    from
		(
        select A.country, A.bin_range, count(*) as cnt
        from 
              (
              select country,
                  case
                  when networth < 10 then '0-10'
                  when networth < 20 then '10-20'
                  when networth < 30 then '20-30'
                  when networth < 40 then '30-40'
                  when networth < 50 then '40-50'
                  when networth < 60 then '50-60'
                  when networth < 70 then '60-70'
                  when networth < 80 then '70-80'
                  when networth < 90 then '80-90'
                  when networth < 100 then '90-100'
                  when networth < 110 then '100-110'
                  when networth < 120 then '110-120'
                  when networth < 130 then '120-130'
                  when networth < 140 then '130-140'
                  when networth < 150 then '140-150'
                  when networth < 160 then '150-160'
                  when networth < 170 then '160-170'
                  when networth < 180 then '170-180'
                  when networth < 190 then '180-190'
                  when networth < 200 then '190-200'
                  end as bin_range
              from billionaires_2021
              ) as A
        group by A.country, A.bin_range
        order by A.country asc, A.bin_range asc
        ) as B
 	group by B.country
    order by B.country;