如何显示没有该日期值的日期

时间:2019-06-19 09:12:45

标签: reporting-services visual-studio-2017

我有一个主表(TMS),其中保存了员工当天在工厂工作的日期和时间,与此相关的还有我派生的表,其中一个表包含执行任务所花费的时间。对于每天的工作,我可以看到他们花在完成一项任务上的时间。我有一瞬间,用户可能不会上班,而是预定时间来完成一项任务。在我的输出Matrix中,因为没有记录他们参加站点,所以不会显示他们预定任务的时间。有没有一种方法可以显示TMS表中的每个日期,无论他们是否已预订?

我创建了一个新表格,该表格显示了从01-01-19到01-01-25的每个日期,希望当我加入上述表格时,在任何日期我们都没有记入或预定的书中“空”是时候完成一项任务了。当我将其加入上述设置时,我仍然没有得到未进行任何计时的日期。

从SSRS 2017的SQL框中复制出的代码(我倾向于使用“网格”窗格进行编码,而不是键入SQL):

SELECT DISTINCT 
                         WOL_TMS_INFO.ORG_UNIT, WOL_TMS_INFO.SAP_NO, format(WOL_TMS_INFO.DATE, 'MM') AS MONTH_PARAM, WOL_TMS_INFO.SITE, WOL_TMS_INFO.FIRSTNAME, WOL_TMS_INFO.SURNAME, 
                         YEAR(WOL_TMS_INFO.DATE) AS YEAR, WOL_TMS_INFO.DATE, WOL_TMS_INFO.HOURS_ATT, format(WOL_TMS_INFO.DATE, 'ddd') AS DATE1, WOL_TMS_INFO.PAID_ABSENCES, WOL_TMS_INFO.HOLIDAY, 
                         WOL_TMS_INFO.HOURS_SICK, HOURS_CUST_PAID_CERV_TBL.HOURS_CUST_PAID, ZPEFF_NP_TIME.NP_WORKING_TIME, CASE WHEN WORKING_TIME IS NULL 
                         THEN 0 ELSE WORKING_TIME END AS WORKING_TIME
FROM            WOL_TMS_INFO LEFT OUTER JOIN
                             (SELECT        TOP (100) PERCENT PERS_NO, PLNT, POSTG_DATE, SUM(WORKING_TIME + CASE WHEN UNIT = 'MIN' THEN ACTUAL_WORK / 60 ELSE ACTUAL_WORK END) AS WORKING_TIME
                               FROM            WOL_ZPEFF_DETAIL
                               GROUP BY PERS_NO, PLNT, POSTG_DATE
                               ORDER BY POSTG_DATE) AS zpeff_derv_tbl_working_time ON WOL_TMS_INFO.DATE = zpeff_derv_tbl_working_time.POSTG_DATE AND WOL_TMS_INFO.SAP_NO = zpeff_derv_tbl_working_time.PERS_NO LEFT OUTER JOIN
                             (SELECT        TOP (100) PERCENT PERS_NO, PLNT, POSTG_DATE, SUM(WORKING_TIME) AS NP_WORKING_TIME
                               FROM            (SELECT        TOP (100) PERCENT PERS_NO, PLNT, POSTG_DATE, SUM(WORKING_TIME + ACTUAL_WORK / 60) AS WORKING_TIME, REASON_FOR
                                                         FROM            WOL_ZPEFF_DETAIL AS WOL_ZPEFF_DETAIL_1
                                                         GROUP BY PERS_NO, PLNT, POSTG_DATE, REASON_FOR
                                                         HAVING         (REASON_FOR IS NOT NULL)
                                                         ORDER BY POSTG_DATE) AS ZPEFF_DERV_DERV_TBL
                               GROUP BY PERS_NO, PLNT, POSTG_DATE
                               ORDER BY POSTG_DATE) AS ZPEFF_NP_TIME ON WOL_TMS_INFO.SAP_NO = ZPEFF_NP_TIME.PERS_NO AND WOL_TMS_INFO.DATE = ZPEFF_NP_TIME.POSTG_DATE LEFT OUTER JOIN
                             (SELECT        TOP (100) PERCENT SAP_NO, DATE, SUM(HOURS_CUST_PAID) AS HOURS_CUST_PAID
                               FROM            WOL_TMS_INFO AS WOL_TMS_INFO_1
                               GROUP BY SAP_NO, DATE
                               ORDER BY DATE) AS HOURS_CUST_PAID_CERV_TBL ON WOL_TMS_INFO.SAP_NO = HOURS_CUST_PAID_CERV_TBL.SAP_NO AND WOL_TMS_INFO.DATE = HOURS_CUST_PAID_CERV_TBL.DATE
WHERE        (WOL_TMS_INFO.ORG_UNIT IN (@PROD_TEAM_PARAM)) AND (WOL_TMS_INFO.SAP_NO IN (@SAP_NO)) AND (format(WOL_TMS_INFO.DATE, 'MM') IN (@MONTH_PARAM)) AND (WOL_TMS_INFO.SITE = 'wolverton') AND 
                         (WOL_TMS_INFO.DATE > '01/01/2019')
ORDER BY MONTH_PARAM, WOL_TMS_INFO.SAP_NO

Matrix的工作原理是不显示没有人花时间预订的时间

1 个答案:

答案 0 :(得分:0)

您可以尝试作为选择的一部分。它应该为您提供工厂时间的时钟,但是如果该时间为空,则为任务预定的时间。

伪代码

ISNULL(ClockInPlantTime,BookToTaskTime)