select row_number() over(order by (je/累计) desc) as 排名,PRODUCTNAME,je,je/累计 as 占比,累加/累计 as 累计占比
from
(
select PRODUCTNAME,je,sum(je) over() as 累计,sum(je) over(order by je) as 累加
from(select PRODUCTNAME,sum(SALE_AMOUNT*PRICE) as je
from sql2002_01 inner join sql2002_03 on sql2002_01.PRODUCTID=sql2002_03.PRODUCTID
group by PRODUCTNAME
) t
) tt where 累加/累计>0.8;