我有以下情况:我在报告中有 16 个查询,它们SELECT
在开始时都使用几乎相同的语句:
SELECT
sereresystem.registrationtime,
CONVERT(VARCHAR(11),DATEADD(DAY,DATEDIFF(DAY,0,sereresystem.registrationtime),0),120) AS [Day],
CAST(datepart(YEAR,sereresystem.registrationtime) AS CHAR(4))+' / KW '+CAST(Datepart(ISO_WEEK,sereresystem.registrationtime) AS VARCHAR(2)) AS [Week],
Datepart(m,DATEADD(MONTH,DATEDIFF(MONTH,0,sereresystem.registrationtime),0)) AS [Month],
CAST(datepart(YEAR,sereresystem.registrationtime) AS CHAR(4))+' / '+CAST(Datepart(q,DATEADD(MONTH,DATEDIFF(MONTH,0,sereresystem.registrationtime),0)) AS VARCHAR(1)) AS [Quarter],
Datepart(year,DATEADD(MONTH,DATEDIFF(MONTH,0,sereresystem.registrationtime),0)) AS [Year],
COUNT(sereresystem.caseid) AS [Total]
FROM sereresystem
INNER JOIN sereregeneral ON sereresystem.caseid=sereregeneral.caseid
INNER JOIN sereresperou ON sereresystem.caseid=sereresperou.caseid
WHERE sereregeneral.inpcha IN(@Inputchannel)
AND sereresperou.assrol IN(@Assigned_Role)
AND sereresystem.registrationtime BETWEEN @Starttime AND @Endtime
AND sereresystem.referencenumber=sereregeneral.renure
GROUP BY sereresystem.registrationtime
我需要日、周、月、季度和年的值在 SSRS 中的这些值之后动态分组。我现在遇到的问题是报告太慢了。是否有可能缩短这 5 个日期选择语句的处理时间?
-edit- 现在是完整的查询