if(count>1, (sale_rank-1)/(count-1), 0) as `percent_rank`
from (select prev_month, curr_month, province,
@i2:=if(prev_month=curr_month,@i2+1,1) as `row_number`,
@i3:=if(prev_month<>curr_month, 1, if(prev_sales=curr_sales,
@i3, @i2)) as ‘sale_rank’, prev_sales, curr_sales
from (select @i1 as prev_month, @i1:=yearmonth as curr_month,
province, @d1 as prev_sales, @d1:=sales as curr_sales
from (select *
from detail
where yearmonth in (201601,201602)
order by yearmonth, sales desc
) t111
) t11
) t1
join
(select yearmonth, province, count(*) count
from detail
where yearmonth in (201601, 201602)
group by yearmonth
) t2
特别提示:本信息由相关用户自行提供,真实性未证实,仅供参考。请谨慎采用,风险自负。
0 条相关评论
相关最新动态
推荐最新动态
点击排行
(c)2008-现在 物流网版权所有 网站地图