【发布时间】:2019-02-23 16:21:24
【问题描述】:
我的 SQL 查询返回:
orderhed_pino_c OrderHed_OrderNum OrderDtl_OrderLine calculated_totalsqm
19.0503 50291 1 1.6359
19.0503 50291 1 1.6359
19.0503 50291 2 1.59244
19.0503 50291 2 1.59244
19.0503 50292 1 28.0476
19.0503 50290 1 3.2718
19.0503 50288 1 7.418808
19.0503 50288 1 7.418808
19.0503 50288 1 7.418808
19.0503 50290 3 1
19.0503 50288 1 7.418808
19.0503 50288 1 7.418808
19.0503 50288 1 7.418808
19.0503 50290 4 38.868
19.0503 50288 1 7.418808
19.0503 50288 1 7.418808
19.0503 50288 1 7.418808
在 SSRS 中,我按 OrderHed_OrderNum 和 OrderDtl_OrderLine 分组
请看图片。
我想要calculate_totalsqm 和orderhed_ordernum 的总数。
但我得到了所有行的总数。
对于orderhed_ordernum = 50291,我有两个orderdtl_orderline 1 和2,所以总数应该是1.6359 + 1.59244 = 3.22834
但 SSRS 显示为 6.45。
我的数据集查询为:
SELECT Sum(t1)
FROM (
SELECT [orderhed_ordernum] AS T2
, Avg([calculated_totalsqm]) AS T1
, [orderdtl_orderline] AS T3
FROM dbo.[baqreportresult_" + parameters!tableguid.value + "]
GROUP BY [orderhed_ordernum], [orderdtl_orderline]
) BB
GROUP BY t2
但我收到错误:
程序 Ice.Services.Lib.RunTask 引发意外异常,并显示以下消息:RunTask: System.Web.Services.Protocols.SoapException: 在报告处理期间发生错误。 ---> Microsoft.ReportingServices.ReportProcessing.ProcessingAbortedException:报告处理过程中发生错误。 ---> Microsoft.ReportingServices.ReportProcessing.ReportProcessingException:数据集“TotalSQM”的查询执行失败。 ---> System.Data.SqlClient.SqlException:关键字'By'附近的语法不正确。****
【问题讨论】:
-
请格式化您的问题,使其可读meta.stackexchange.com/questions/22186/…
-
在查询中你引用的参数不是
@tableguid吗? -
但我不认为你可以使用参数创建动态 SQL
-
请帮忙,有什么好的方法可以做到这一点?
-
我不知道 - 从你的问题中不清楚你想要达到什么目的......你有多少不同的桌子?
标签: reporting-services ssrs-2008