select tt.*,
  case
        when tt.faverageamount < 10000 then '1wÒÔÏÂ'
        when tt.faverageamount < 30000 then '1-3w'
        when tt.faverageamount < 50000 then '3-5w'
        when tt.faverageamount < 100000 then '5-10w'
        when tt.faverageamount < 200000 then '10-20w'
        when tt.faverageamount < 500000 then '20-50w'
        when tt.faverageamount < 1000000 then '50-100w'
        else '100wÒÔÉÏ' end fclass
 from (
    select t2.fprovince,t2.fcity,t2.fcounty,t2.fagentnum,t2.fagentname,sum(t1.famount)famount,sum(t1.famount)/12  as faverageamount
    from DSBCRM..tagents_purchase t1
    inner join DSBCRM..tagents t2 on t1.siteid = t2.siteid and t1.tagentsid = t2.tagentsid
    where t1.fyear =$fyear$ and t1.siteid=$siteid$ and t2.fsaleruserid in $tenterprise_userid$
    group by t2.fprovince, t2.fcity, t2.fcounty, t2.fagentnum, t2.fagentname
)tt