select rank() over(order by (销售金额/累计) desc) as 排名,PRODUCTNAME as 产品名称,销售金额,(销售金额/累计) as 占比,(累加/累计) as 累计占比 from ( select PRODUCTNAME,销售金额,sum(销售金额) over() as 累计,sum(销售金额) over(order by 销售金额) as 累加 from ( select PRODUCTNAME,sum(SALE_AMOUNT*PRICE) as 销售金额 from sql2002_01 inner join sql2002_03 on sql2002_01.PRODUCTID=sql2002_03.PRODUCTID group by PRODUCTNAME ) t ) tt where 累加/累计>0.8; |