Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/reporting-services/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Sql SSRS参数不返回单个结果_Sql_Reporting Services_Parameters_Parent Child - Fatal编程技术网

Sql SSRS参数不返回单个结果

Sql SSRS参数不返回单个结果,sql,reporting-services,parameters,parent-child,Sql,Reporting Services,Parameters,Parent Child,我目前有一个报告设置,返回一个基于4个参数的结果。这些参数是@StartDate、@EndDate、@EmployeeID和@SampleType,它们都可以很好地解释。它还按样本类型分组,然后按日期分组 该报告大致如下所示: (名称是一个计算字段,按employeeID分组) 如果有多行要返回,报表将返回正确的结果,但是如果只有一行要返回,则不显示任何内容。它不会仅对特定的employeeID或特定的SampleType执行此操作,只有在只有一条记录要显示时才会执行此操作。因此,使用上面的虚拟

我目前有一个报告设置,返回一个基于4个参数的结果。这些参数是@StartDate、@EndDate、@EmployeeID和@SampleType,它们都可以很好地解释。它还按样本类型分组,然后按日期分组

该报告大致如下所示:

(名称是一个计算字段,按employeeID分组) 如果有多行要返回,报表将返回正确的结果,但是如果只有一行要返回,则不显示任何内容。它不会仅对特定的employeeID或特定的SampleType执行此操作,只有在只有一条记录要显示时才会执行此操作。因此,使用上面的虚拟报告,如果@StartDate为4/6,@EndDate为4/6,@EmployeeID为Name1,@SampleType为B,预览将不会显示单个结果。但如果@EmployeeID是Name2,则它将同时包含两行

当只有一行返回时,是否有任何明显的原因使参数无法正常工作

以下是查询的副本:

    SELECT        MasterSampleDescription, CollectedDateTime, LabArrivalDateTime, CreatedDateTime, TimeDiffCollectLab, TimeDiffLabCreate, TimeDiffCollectCreate, 
                     TimeDiffCollectStart, TimeDiffCollectEnd, TimeDiffSampleStartEnd, SampleStart, SampleEnd, FirstName, LastName, AVG(TimeDiffCollectEnd) AS AvgTimeDiffCollect, 
                     TimeDiffLabArrivalSampleEnd, TimeDiffCreationStart, UserID
    FROM            vwTimeAnalysis
    WHERE        (CollectedDateTime >= @StartDate) AND (CollectedDateTime < DATEADD(Day, 1, @EndDate))
    GROUP BY MasterSampleDescription, CollectedDateTime, LabArrivalDateTime, CreatedDateTime, TimeDiffCollectLab, TimeDiffLabCreate, TimeDiffCollectCreate, 
                     TimeDiffCollectStart, TimeDiffCollectEnd, TimeDiffSampleStartEnd, SampleStart, SampleEnd, FirstName, LastName, TimeDiffLabArrivalSampleEnd, 
                     TimeDiffCreationStart, UserID
    HAVING        (UserID = @EmployeeName) AND (MasterSampleDescription = @SampleType)
    ORDER BY CollectedDateTime, LastName, MasterSampleDescription
选择MasterSampleDescription、CollectedDateTime、LabArrivalDateTime、CreatedDateTime、TimeDiffCollectLab、TimeDiffLabCreate、TimeDiffCollectCreate、,
TimeDiffCollectStart、TimeDiffCollectEnd、TimeDiffSampleStartEnd、SampleStart、SampleEnd、FirstName、LastName、AVG(TimeDiffCollectEnd)作为AvgTimeDiffCollect,
TimeDiffLabArrivalSampleEnd,TimeDiffCreationStart,用户ID
从时间分析
其中(CollectedDateTime>=@StartDate)和(CollectedDateTime
如果“预览”是指Visual Studio中的“预览”选项卡,那么我将忽略此选项。这通常是不可靠的/误导性的。部署报表并在用户运行报表时对其进行测试。

HAVING子句用于聚合函数条件。My bad,QueryDesigner将这些过滤器默认为HAVING,而不是WHERE。更正了查询,仍然没有看到所需的结果。它从查询中正确地提取行,但无法在报告中显示它们。这听起来更像是SSRS问题,而不是查询问题。你能给我们更多关于(大概是矩阵)控制设置的信息吗?有什么特别的事吗?您的组定义是什么?如果“预览”是指Visual Studio中的“预览”选项卡,那么我会忽略这一点。这通常是不可靠的/误导性的。部署您的报告,并在用户运行报告时对其进行测试。@MikeHoney谢谢。它显然在Dev中工作,只是不在visualstudio的预览选项卡中。让我无缘无故地疯狂。非常感谢你。
    SELECT        MasterSampleDescription, CollectedDateTime, LabArrivalDateTime, CreatedDateTime, TimeDiffCollectLab, TimeDiffLabCreate, TimeDiffCollectCreate, 
                     TimeDiffCollectStart, TimeDiffCollectEnd, TimeDiffSampleStartEnd, SampleStart, SampleEnd, FirstName, LastName, AVG(TimeDiffCollectEnd) AS AvgTimeDiffCollect, 
                     TimeDiffLabArrivalSampleEnd, TimeDiffCreationStart, UserID
    FROM            vwTimeAnalysis
    WHERE        (CollectedDateTime >= @StartDate) AND (CollectedDateTime < DATEADD(Day, 1, @EndDate))
    GROUP BY MasterSampleDescription, CollectedDateTime, LabArrivalDateTime, CreatedDateTime, TimeDiffCollectLab, TimeDiffLabCreate, TimeDiffCollectCreate, 
                     TimeDiffCollectStart, TimeDiffCollectEnd, TimeDiffSampleStartEnd, SampleStart, SampleEnd, FirstName, LastName, TimeDiffLabArrivalSampleEnd, 
                     TimeDiffCreationStart, UserID
    HAVING        (UserID = @EmployeeName) AND (MasterSampleDescription = @SampleType)
    ORDER BY CollectedDateTime, LastName, MasterSampleDescription