SELECT eq.emp3,eq.wages,

CASE WHEN eq.ave_wages = 0 then '0'

WHEN eq.ave_wages between 0 AND 500 then '0-500'

WHEN eq.ave_wages between 501 and 1000 then '501-1000'

WHEN eq.ave_wages between 1001 and 1500 then '1001-1500'

WHEN eq.ave_wages between 1501 and 2000 then '1501-2000'

WHEN eq.ave_wages between 2001 and 2500 then '2001-2500'

WHEN eq.ave_wages between 2501 and 3000 then '2501-3000'

WHEN eq.ave_wages between 3001 and 3500 then '3001-3500'

WHEN eq.ave_wages between 3501 and 4000 then '3501-4000'

WHEN eq.ave_wages between 4001 and 4500 then '4001-4500'

WHEN eq.ave_wages between 4501 and 5000 then '4501-5000'

WHEN eq.ave_wages between 5001 and 5500 then '5001-5500'

WHEN eq.ave_wages between 5501 and 6000 then '5501-6000'

WHEN eq.ave_wages between 6001 and 6500 then '6001-6500'

WHEN eq.ave_wages between 6501 and 7000 then '6501-7000'

WHEN eq.ave_wages between 7001 and 7500 then '7001-7500'

WHEN eq.ave_wages >= 7500 then '7500+' end wage_range,

from

(select distinct eq.emp3,eq.wages, sum(eq.emp1)emp1,sum(eq.emp2)emp2,

sum(eq.emp3)emp3,sum(eq.wages)wages,round(avg(emp1 + emp2 + emp3)/wages) ave_wages

FROM b_owner._eqi eq

WHERE eq.yrqtr = 20181

and eq.meei != 2)

Any tips?