WITH A AS ( SELECT COUNT ( NAME ) AS TRADITIONSUM FROM ODBusiness.DBO.ONCONTRACT WHERE DATEDIFF( MONTH, [INPUTTIME], GETDATE( ) ) = 0 AND PMCSUM NOT IN ('0') ), B AS ( SELECT COUNT ( NAME ) AS TRADITIONSUM FROM ODBusiness.DBO.ONCONTRACT WHERE DATEDIFF( MONTH, [INPUTTIME], GETDATE( ) ) = 1 AND PMCSUM NOT IN ('0') ) SELECT CAST((A.TRADITIONSUM - B.TRADITIONSUM) AS FLOAT) /(B.TRADITIONSUM) FROM A, B |