SSRS报告中的数据太长

时间:2016-02-25 16:01:30

标签: sql reporting-services parameters parameter-passing subreport

我正在为出勤创建报告,一旦用户点击注册子报告,它应该显示15-20名学生的特定注册。

MainReport

但我看到大约60页的数据太长了。

Subreport

我正在过滤掉参数,但我的mgr想要选择所有参数。

查询:

---------delete existing warehouse table------------------------------
IF OBJECT_ID('dbo.WarehouseAttendance', 'U') IS NOT NULL
DROP TABLE dbo.WarehouseAttendance; 
--------Create New Table--------------------------------------------------
---Weeks-------------------------------------------------------------------------------
With weeks as 
(select VDC_week_no, VDC_cal_year, min(VDC_day_date) as WeekCommence
from sql10.ng.dbo.Vdaily_calender
where VDC_avail = 'T'
group by VDC_week_no, VDC_cal_year),

---TTWeeks-----------------------------------------------------------------------------
TTWeeks as

(SELECT VDC_Cal_Year as REMSYear, [VDC_week_no] as WholeYearWeekNo, WeekCommence
, ROW_NUMBER() OVER(PARTITION BY vdc_cal_year ORDER BY VDC_week_no) as TermTimeWeekNo FROM weeks)

---Main-----------------------------------------------------------------------------------
SELECT    CASE WHEN STYR_Age_end_Aug < 16 THEN '1416' WHEN STYR_Age_end_Aug < 19 THEN '1618' ELSE '19+' END AgeBand,
REGT_Year, RTRIM(PRPH_ML1) AS PRPH_ML1, RTRIM(PRPH_ML2) AS PRPH_ML2, 
ML2.GNCD_Description AS [Curriculum Area], RTrim(PRPH_ML2) AS Section, 
q.GNCD_Description AS Section_Name, LEFT(q.GNCD_Description, 3) AS Dept, 
rtrim(REGT_Provision_Code) as REGT_Provision_Code, rtrim(PRPH_Title) as PRPH_Title, REGT_Student_ID, STEN_Funding_Stream, STYR_Age_end_Aug, REGS_Session_No, 
rtrim(REGH_Class_Register) as REGH_Class_Register, RTRIM(REGH_Register_Title) as REGH_Register_Title, REGH_Day, 
      CASE WHEN REGH_Day = '1' THEN 'Sunday' WHEN REGH_Day = '2' THEN 'Monday' 
      WHEN REGH_Day = '3' THEN 'Tuesday' WHEN REGH_Day = '4' THEN 'Wednesday'
       WHEN REGH_Day = '5' THEN 'Thursday' WHEN REGH_Day = '6' THEN 'Friday' 
       WHEN REGH_Day = '7' THEN 'Saturday' END AS Register_Day, 
       [REGH_Start_Time] ,[REGH_End_Time],
      CASE WHEN (REGTrgstudt.REGT_Provision_Code LIKE '27%' OR
      REGT_Provision_Code LIKE 'MA27%' OR
      REGT_Provision_Code LIKE 'FS%') 
      THEN 'FunctionalSkill' 
      WHEN REGT_Provision_Code LIKE '16%' THEN 'GCSE' WHEN REGT_Provision_Code LIKE '%/F%' OR
      REGT_Provision_Code LIKE '%/D%' OR
      REGT_Provision_Code LIKE '%/E%' OR
      REGT_Provision_Code LIKE '%/X%' THEN 'Main' ELSE 'Addition' END AS CourseType, 
      CASE WHEN isnull(RGAT_Present,'X') IN ('N', 'Y','X') and REGS_Session_Date<GETDATE()
      THEN REGS_Duration - isnull(REGD_Mins_Late,0) ELSE 0 END AS Mins_Poss, 
      CASE WHEN isnull(RGAT_Present,'X') = 'Y' and REGS_Session_Date<GETDATE() THEN 
      REGS_Duration - REGD_Mins_Late ELSE 0 END AS Mins_Att, 
      CASE WHEN RGAT_Present = 'Y' and REGS_Session_Date<GETDATE() THEN REGD_Mins_Late ELSE 0 END AS Mins_Late, 
      [REGS_Session_Date] as Session_Date,
      TermTimeWeekNo,
      REGH_ISN, PRPH_ISN, STUD_Surname, STUD_Forename_1, REGD_Attendance_Mark,
      REGT_start_date, REGT_End_date, WeekCommence
INTO WarehouseAttendance                    
FROM  sql10.ng.dbo.REGTrgstudt INNER JOIN
      sql10.ng.dbo.REGSrgsessn ON REGT_REGH_ISN = REGS_REGH_ISN  
      inner join sql10.ng.dbo.Vdaily_calender
      ON REGS_Session_Date=VDC_day_date      
      INNER JOIN TTWeeks on REGT_year=TTWeeks.REMSYear
      and VDC_week_no=WholeYearWeekNo and VDC_cal_year=REMSYear
      INNER JOIN
      sql10.ng.dbo.REGHrghdr ON REGH_ISN = REGT_REGH_ISN 
      INNER JOIN
      sql10.ng.dbo.PRPHProvisionHeader ON REGT_Provision_Code = PRPH_Code 
      INNER JOIN
      sql10.ng.dbo.GNCDgncodes AS ML2 ON ML2.GNCD_General_Code = PRPH_ML2 AND ML2.GNCD_Code_Type = 'M2' 
      INNER JOIN sql10.ng.dbo.STEN ON STEN_Student_ID = REGTrgstudt.REGT_Student_ID AND STEN_Provision_Code = REGTrgstudt.REGT_Provision_Code AND
STEN_Provision_Instance = REGT_Provision_Instance 
INNER JOIN sql10.ng.dbo.STYRstudentYR ON STYR_Student_ID = REGT_Student_ID AND 
STYR_Year = REGT_Year   
INNER JOIN (SELECT ACYR_College_Year FROM sql10.ng.dbo.ACYR WHERE      (ACYR_College_Year in (2015, 2014, 2013, 2012))) AS SUB ON REGT_Year = SUB.ACYR_College_Year
INNER JOIN sql10.ng.dbo.STUDStudent on STYR_Student_ID=STUD_Student_ID
INNER JOIN sql10.ng.dbo.REGDropin ON REGT_REGH_ISN = REGD_REGH_ISN AND 
REGT_Student_ID = REGD_Student_ID AND REGD_Session_No = REGS_Session_No
INNER JOIN sql10.ng.dbo.RGATAttendance ON REGD_Attendance_Mark = RGAT_Attendance_Code 
INNER JOIN sql10.ng.dbo.PRPIProvisionInstance AS pit ON pit.PRPI_Code = REGT_Provision_Code and pit.prpi_instance = REGT_Provision_Instance
INNER JOIN (SELECT GNCD_General_Code, GNCD_Description FROM sql10.ng.dbo.GNCDgncodes WHERE (GNCD_Code_Type = 'M2'))AS q ON q.GNCD_General_Code =  RTrim(PRPH_ML2) 
END

Dataset1:

    SELECT PRPH_ML1, Section, Section_Name, AgeBand, TermTimeWeekNo, SUM(Mins_Poss) AS Mins_Poss, SUM(Mins_Att) AS Mins_Att, SUM(Mins_Late) AS Mins_Late, 
    REGT_Provision_Code, PRPH_Title, 
    REGH_Class_Register + ' - ' + REGH_Register_Title COLLATE DATABASE_DEFAULT + ' - ' + Register_Day COLLATE DATABASE_DEFAULT + '  ' + CONVERT(char(5),REGH_Start_Time, 108) + ' - ' + CONVERT(char(5), REGH_End_Time, 108) AS Register
    FROM  WarehouseAttendance
    WHERE (REGT_Year = @Year) AND (AgeBand IN (@AgeBand)) AND (CourseType IN (@CourseType))
    GROUP BY PRPH_ML1, Section, Section_Name, AgeBand, TermTimeWeekNo, REGT_Provision_Code, PRPH_Title, REGH_Class_Register, REGH_Register_Title, Register_Day, REGH_Start_Time, REGH_End_Time
    ORDER BY REGT_Provision_Code

Dataset2:

    SELECT DISTINCT AgeBand
    FROM            WarehouseAttendance
    WHERE        (REGT_Year = @Year)

你能说明我哪里出错吗?

1 个答案:

答案 0 :(得分:0)

在子报告中,我包含了寄存器值的过滤器,现在它可以正常工作。