|
我也来练一练
两种百分比都求了一下
- select 品种,x.分公司,x.分类销量,x.分类销量/y.总销量 as 百分比,x.分类销量/z.分类销量 as 分类占比 from
- (select 品种,分公司,sum(数量) as 分类销量 from [Sheet1$] group by 品种,分公司) x,
- (select sum(数量) as 总销量 from [Sheet1$]) y,
- (select 分公司,sum(数量) as 分类销量 from [sheet1$] group by 分公司) z
- where x.分公司=z.分公司
复制代码- select 品种,x.分公司,x.分类销量,x.分类销量/y.总销量 as 百分比,x.分类销量/z.分类销量 as 分类占比 from
- (select 品种,分公司,数量 as 分类销量 from [Sheet1$]) x,
- (select sum(数量) as 总销量 from [Sheet1$]) y,
- (select 分公司,sum(数量) as 分类销量 from [sheet1$] group by 分公司) z
- where x.分公司=z.分公司
复制代码
zyh196712练习求占比.rar
(15.03 KB, 下载次数: 127)
[ 本帖最后由 zyh196712 于 2010-8-17 12:44 编辑 ] |
|