个人组(树)的总和 [英] sum by individual group (tree)

查看:53
本文介绍了个人组(树)的总和的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有3张桌子; item_master,订单和帮助。我的项目结构如下:

一般(等级1)

| ____内容(等级2)

| | ___ GnMain(等级3)

| | | __vb6

| | | __vb.net

| | | __c#

| | | __f#

| | ______ jq

| | ______ js

| ____________ java



我的问题是如何获得每个级别的个别总和并将其插入帮助表中订购可能有6个产品。在一个订单中每个不同的数量。



一种方法是在插入每个项目时更新帮助程序表,但如果级别增加,这将导致表演者问题,如果更多物品在客户的订单中。





foreach item

调用udf获取父母,祖父母,伟大的祖父母等视情况申请

然后

foreach父母更新oldsum + newsum



我需要一个出路或指向一篇能够完美解决这项业务需求的文章。



提前感谢每一个。

解决方案

您可以使用GROUPING SETS,请参阅博客帖子 [ ^ ]

I have 3 tables; item_master, order & helper. my item structure is like:
General (level1)
|____Content (level2)
| |___GnMain (level3)
| | |__vb6
| | |__vb.net
| | |__c#
| | |__f#
| |______jq
| |______js
|____________java

my question is how can i get the individual sum of each level and insert it into the helper table if customer order for maybe 6 of the product. at different quantities each in one order.

one way is to update the helper table while inserting each item but this will cause performers problem if the levels increase and also if more items are in the customer''s order.
that is

foreach item
call udf to get parent, grandparent, greatgrandparent etc as the case may apply
then
foreach parents update oldsum+newsum

please i need a way out or point me to an article that can solve this business need perfectly.

thanks every one in advance.

解决方案

You can use GROUPING SETS, Refer Blog Post[^]


这篇关于个人组(树)的总和的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆