SELECT CONVERT( VARCHAR ( 10 ), c.InputTime, 23 ) AS 对比年月,c.CONTRACTSUM AS 本月金额,d.CONTRACTSUM AS 去年同期金额,CASEWHEN d.CONTRACTSUM IS NULL OR d.CONTRACTSUM= 0 THEN'无穷大' ELSE CAST (CAST (( isnull( c.CONTRACTSUM, 0 ) - isnull( d.CONTRACTSUM, 0 ) ) * 100 / isnull( d.CONTRACTSUM, 0 ) AS DECIMAL ( 10, 2 ) ) AS VARCHAR ( 50 ) ) + '%' END AS 同比 FROMdbo.outCONTRACT cLEFT JOIN (SELECTa.CONTRACTSUM AS CONTRACTSUM,a.InputTime AS lsInputTime,b.InputTime AS InputTime FROMdbo.outCONTRACT aJOIN dbo.outCONTRACT b ON a.InputTime= DateAdd( YEAR, - 1, b.InputTime ) ) d ON c.InputTime= d.InputTime