我想得到所有网站的百分比。。。我试过加州大学旧金山分校,但错了
SELECT A.Year
,A.Month
,(sum(A.BCHO) * 100 / NULLIF((sum(B.BCHO)), 0)) AS BCHO
,
--SELECT FORMAT((37.0/38.0),'P3') as [ThreeDecimalsPercentage]
FORMAT((sum(A.UCSF)) * 100 / (sum(B.UCSF)), 'P2') AS UCSF_P
,-------------------This is wrong
(sum(A.UCSF) * 100 / (sum(B.UCSF))) AS UCSF
,(sum(A.UCLA) * 100 / (sum(B.UCLA))) AS UCLA
,(sum(A.UCD) * 100 / (sum(B.UCD))) AS UCD
,(sum(A.UCI) * 100 / (sum(B.UCI))) AS UCI
,(sum(A.UCSD) * 100 / (sum(B.UCSD))) AS UCSD
FROM Denials_Scrub_Final_V A
INNER JOIN Claims_Final_V B ON B.Year = A.Year
AND A.Month = B.Month
GROUP BY A.Year
,A.Month
,A.UCSF
,B.UCSF
ORDER BY A.Year
,A.Month
2条答案
按热度按时间d5vmydt91#
我就是这样格式化的。。。
2exbekwf2#
sql server执行整数除法。要获取小数位,请使用
100.0
而不是100
:如果您特别希望结果中有两位数字,请使用
round()
或转换为decimal
,例如decimal(5, 2)
或使用format()
.