当前位置: 代码迷 >> PB >> 请问:怎么把分类合计汇总在最后啊
  详细解决方案

请问:怎么把分类合计汇总在最后啊

热度:87   发布时间:2016-04-29 10:10:51.0
请教:如何把分类合计汇总在最后啊?
GoodsId GoodsName color Goodsnumber
A0001 男休闲外套 红色 22
A0002 女休闲外套 红色 5
A0003 男休闲T-shirt 蓝色 88
A0004 男休闲T-shirt 白色 35
A0005 男衬衫 白色 13
A0006 女短袖 红色 20
A0007 男袜 蓝色 77
A0008 裤子 白色 1

汇总: 红色 47
蓝色 165
白色 49
如上所示,DW里要怎么才可以实现?谢谢

------解决方案--------------------
添加计算列, 表达式为:
'红色 ' + string(sum(if(color = '红色', Goodsnumber, 0) for all))
这是取红色的,其它类似
这样做局限性较大,当color类型较多时比较繁琐,而且无法动态汇总

你可以添加group,不过这样一来汇总信息就不是显示在最后了。

------解决方案--------------------
加with cube 可以。

select .... from t
group by ....
 with cube
------解决方案--------------------
做俩DW
------解决方案--------------------
分两个dw吧 然后做成复合DW
------解决方案--------------------
retrieve后
写:
C/C++ code
long ll_c, istring ls_color, ls_all = "汇总:"for i = 1 to long(dw_1.describe("evaluate('count(color for all distinct)', 0)"))    //按color升序取颜色    ls_color = dw_1.describe("evaluate('Small(color, color, " + string(i) + " for all distinct)',0)")    ls_all += "~t" + ls_color + ":" + dw_1.describe("evaluate('sum(if(color = ~"" + ls_color + "~", Goodsnumber, 0) for all)', 0)")nextmessagebox('', ls_all)
  相关解决方案