找出SQL

时间:2016-12-04 21:43:03

标签: sql-server sql-server-2008

我正在尝试查找以下查询的每月百分比(过去12个月)

明智地说,如果有人能帮助我,那就太棒了

SELECT Month(a.[Work Initated Date]) AS Month, a.[Initial Severity],

(CAST(Count(a.[Case Number]) AS Decimal(10,1))/ (select CAST(Count(a.[Case Number]) AS Decimal(10,1)) 

FROM [DSTRINING].[dbo].[SFDC WorkInitiated]  (nolock) a 


where  a.[Initial Severity]='Critical' AND Month(a.[Work Initated Date])=Month(getdate()))*100) AS 'Work Initated%'

FROM [DSTRINING].[dbo].[SFDC WorkInitiated]  (nolock) a

where a.[Initial Severity]='Critical' AND Month(a.[Work Initated Date])=Month(getdate()) AND a.[Work Initiated Target Breached]='NO' 

Group by Month(a.[Work Initated Date]), a.[Initial Severity]

0 个答案:

没有答案