在Fanout上产生准确的尺寸
我的数据模型:
查询:
SELECT
ProductSummary.Product,
ProductSummary.ID AS SummaryID,
Transactions.DateOfSale,
Summary.Revenue
FROM
ProductSummary JOIN
Transactions ON (Transactions.ProductID = ProductSummary.ID)
WHERE
Transactions.DateOfSale < '2014-01-10'
数据本身看起来不错,但是我也想显示一个小计,表的小计应该是当未连接该表时显示的数量。
例如,对于次序收入,答案应始终是我从中从摘要
中获得的(收入)(应用于任何必要的过滤器之后)。如何生成?
My data model:
The query:
SELECT
ProductSummary.Product,
ProductSummary.ID AS SummaryID,
Transactions.DateOfSale,
Summary.Revenue
FROM
ProductSummary JOIN
Transactions ON (Transactions.ProductID = ProductSummary.ID)
WHERE
Transactions.DateOfSale < '2014-01-10'
The data itself looks fine, however I also want to show a subtotal, and the subtotal of a table should be the amount displayed when that table is not joined.
For example, for subtotaling Revenue the answer should always be what I would get from SELECT SUM(Revenue) FROM Summary
(after applying any necessary filters). How to generate that?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
做到这一点的一种方法是使用分析函数来计数唯一的行,例如:
One way to do this would be using an analytic function to count the unique rows while totaling, for example: