SQL Server Reporting Services 2005 - 如何将条件总计放入标题行

发布于 2024-08-18 02:33:51 字数 447 浏览 4 评论 0原文

假设我有一个像这样的表:

Customer,Invoice Type,Balance
A,Good,50
A,Good,10
A,Bad,20
B,Good,20

我想制作这样的报告:

Customer,Invoice Type,Balance,Total Adjusted Balance
A            40    
   Good
        50
        10    
   Bad
        20 
B            20    
   Good
        20

其中调整后余额总额是良好发票余额的总和减去客户不良发票余额的总和。

调整后的平衡是我在布局编辑器中使用表达式来计算的吗?或者有更好的方法吗?

(如果我需要在布局编辑器中使用表达式,我该怎么做?)

Let's say I have a table like this:

Customer,Invoice Type,Balance
A,Good,50
A,Good,10
A,Bad,20
B,Good,20

And I want to make a report like this:

Customer,Invoice Type,Balance,Total Adjusted Balance
A            40    
   Good
        50
        10    
   Bad
        20 
B            20    
   Good
        20

Where total adjusted balance is the sum of the good invoice balances minus the sum of the bad for a customer.

Is adjusted balance something I use an expression in the layout editor to calculate? Or is there a better way?

(If I need to use an expression in the layout editor, how do I do it?)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

高跟鞋的旋律 2024-08-25 02:33:51

您只需要对标题中的字段进行求和即可。

Reporting Services 非常了解上下文或“范围界定”。

因此,如果您有不同的分组,即国家、州、城镇,

通过引用您希望对每个分组求和的值(例如 SalesAmt),它只会对该特定组内的那些值求和。

http://msdn.microsoft.com/en-us/library/bb630415。 ASPX

You just need to SUM up the fields in the header.

Reporting Services is very aware of context or "Scoping".

So if you have different groupings i.e. Country, State, Town

By refering to the value you wish to sum for each of these (e.g. SalesAmt), it will only sum for those values within that particular group.

http://msdn.microsoft.com/en-us/library/bb630415.aspx

甚是思念 2024-08-25 02:33:51

我从来没有使用过SSRS,所以我不知道是否有任何预定义的方法来计算它。您可以使用以下 SQL 来完成此操作:

SELECT
  Customer,
  [Invoice Type],
  Balance,
  SUM(CASE WHEN [Invoice Type] = 'Good' THEN Balance ELSE -Balance END) OVER (PARTITION BY Customer) AS [Total Adjusted Balance]
FROM table1;

I've never used SSRS so I don't know if there's any predefined way to calculate it. You can do it using the following SQL:

SELECT
  Customer,
  [Invoice Type],
  Balance,
  SUM(CASE WHEN [Invoice Type] = 'Good' THEN Balance ELSE -Balance END) OVER (PARTITION BY Customer) AS [Total Adjusted Balance]
FROM table1;
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文