SSRS 보고서 빌더 응용 프로그램을 사용하여 매월 기록 된 사고의 수를 추적하는 시스템에 대한 BI 보고서를 작성합니다.이번 달에 마감 된 이전 달의 날짜를 얻는 방법
아래 나 쿼리
Month Logged Received Closed Remaining
January 200 220 150 70
February 150 220 200 20
March 110 130 100 30
April 200 230 200 30
을 만들어야 테이블이며, 각 열은 다음과 같이 정의에서
기록 된 = 오픈 사고 오픈 예 당월 1/1/2014 년 1 월 1 일부터 3114 년 1 월 31 일까지 (현재 월 데이터 만 포함)
Received = 기록 된 사고 + 아직 열리지 않은 이전 달의 남은 잔여 누계 지난 달 남은 g ive me 총 220입니다. 현재 달에 개폐 이번 달에 +를
남은 =받은이 달에 폐쇄 전월 남아있다
청산 = 사건 -
내가 사용되는 코드
폐쇄SELECT group_id, YEAR(Opendate) AS Year, MONTH(Opendate) AS Month,
COUNT(CASE WHEN Month(Closedate) = Month(Opendate)
AND Month(closedate)> Month (opendate) THEN 1 ELSE NULL END) AS closed,
COUNT(*) AS Logged,
FROM Incidents
WHERE (Opendate >= @YearStart) AND (Opendate <= @YearEnd)
GROUP BY YEAR(Opendate), MONTH(Opendate), group_id
ORDER BY Year, Month,group_id
:
아래 현재 월에 폐쇄되었다 또한 단지 나에게주는 이전 달 동안 나에게 가까이 사건을 포기하지 않는 것은 내가 내 쿼리에 사용되는 코드입니다
로깅 된 상태가 정상적으로 작동합니다. 수신 및 남아 있습니다.
나는 Union
를 사용하려하고 내가받은 데이터는 다음과 같습니다 로그온 및 폐쇄 데이터
Select count(*) logged,year(opendate) as year1,MONTH(opendate) as
month1,'Logged' as status1
From Incidents
where opendate is not null
GROUP BY year(opendate),MONTH(opendate)
UNION
Select count(*) closed,year(Closedate) as year1,MONTH(Closedate) as
month1,'All_Closed' as status1
From Incidents
where Closedate is not null
GROUP BY year(Closedate),MONTH(Closedate)
UNION
Select count(*) Remaining,year(opendate) as year1,MONTH(opendate) as
month1,'Current_Month_Not_Closed' as status1
From Incidents
where Month(Closedate) > MONTH(Opendate)
GROUP BY year(opendate),MONTH(opendate)
UNION
Select count(*) Month_Closed,year(opendate) as year1,MONTH(opendate) as
month1,'Current_Month_Close' as status1
From Incidents
where MONTH(Closedate) = MONTH(Opendate)
GROUP BY year(opendate),MONTH(opendate)
order by year1,month1
을 가지고 : 티켓의 수있을 것입니다 수신
logged | year1 | month1 | status1
-------+-------+--------+-------------------------
1093 | 2014 | 1 | Logged
1089 | 2014 | 1 | All_Closed
997 | 2014 | 1 | Current_Month_Close
96 | 2014 | 1 | Current_Month_Not_Closed
1176 | 2014 | 2 | Logged
1176 | 2014 | 2 | All_Closed
91 | 2014 | 2 | Current_Month_Not_Closed
1085 | 2014 | 2 | Current_Month_Close
1340 | 2014 | 3 | Logged
1327 | 2014 | 3 | All_Closed
107 | 2014 | 3 | Current_Month_Not_Closed
1232 | 2014 | 3 | Current_Month_Close
116 | 2014 | 4 | Current_Month_Not_Closed
1320 | 2014 | 4 | Current_Month_Close
1424 | 2014 | 4 | All_Closed
1441 | 2014 | 4 | Logged
1167 | 2014 | 5 | Current_Month_Close
105 | 2014 | 5 | Current_Month_Not_Closed
1277 | 2014 | 5 | Logged
1283 | 2014 | 5 | All_Closed
날짜를 – Muneera