SELECT ROW_NUMBER() OVER ( ORDER BY b.年 ) AS ID , b.YearTime ,CAST(ISNULL(c.Profit, 0) AS DECIMAL(18,2)) as Profit ,b.Dates,CAST(ISNULL(c.ProfitRate,0) AS DECIMAL(18,2)) as ProfitRate
FROM ( SELECT RTRIM(a.年) + ‘-’ + RTRIM(t.number) AS Dates ,a.YearTime ,a.年 ,t.number 月
FROM ( SELECT DISTINCT YearTime AS 年 ,YearTime
FROM dbo.AccountMonthReport) a ,master.dbo.spt_values t
WHERE t.type = ‘p’
AND t.number >= 1
AND t.number <= 12
) b
LEFT JOIN AccountMonthReport AS c ON b.年 = c.YearTime AND b.月 = c.MonthTime AND b.YearTime = c.YearTime
AND c.Account=844169
sql补全月份
最新推荐文章于 2022-01-14 17:32:52 发布