我在转换这个十进制值时遇到了一些问题,如下所示:
21.6080402010050
谁能帮我把它转换成21.6
?
我已经尝试过了,但它不起作用。
(convert(decimal(10, 2), SUM(t1.TOTAL))
这是查询
SELECT
t1.LINE_NO, t1.E_FIELD, t1.F_FIELD, t1.G_FIELD, t1.HSA_STATUS,
t1.FAMILY, t1.CACHE_FAMILY,
SUM(t1.TOTAL) AS CountOfLineNo, t2.TotalOfLineNo,
(convert(decimal(8,1), SUM(t1.TOTAL)) * 100 / t2.TotalOfLineNo ) AS Percentage
FROM (
SELECT
LINE_NO, E_FIELD,F_FIELD,G_FIELD,HSA_STATUS,FAMILY,CACHE_FAMILY,
Count(LINE_NO) as Total
FROM TX_HSA_SUMM
WHERE MT_TIMESTAMP2 BETWEEN ('2013-03-07 10:10:00') AND ('2013-03-08 10:20:00')
GROUP BY LINE_NO, E_FIELD, F_FIELD, G_FIELD, HSA_STATUS, FAMILY, CACHE_FAMILY) AS t1
LEFT JOIN (
SELECT LINE_NO, COUNT(LINE_NO) AS TotalOfLineNo
FROM TX_HSA_SUMM
WHERE MT_TIMESTAMP2 BETWEEN ('2013-03-07 10:10:00') AND ('2013-03-08 10:20:00')
GROUP BY LINE_NO) AS t2 ON t1.LINE_NO = t2.LINE_NO
GROUP BY
t1.LINE_NO, t1.E_FIELD, t1.F_FIELD, t1.G_FIELD, t1.HSA_STATUS, t1.FAMILY,
t1.CACHE_FAMILY, t1.Total, t2.TotalOfLineNo
ORDER BY
t1.LINE_NO, t1.E_FIELD, t1.F_FIELD, t1.G_FIELD, t1.HSA_STATUS, t1.FAMILY,
t1.CACHE_FAMILY, t1.Total, t2.TotalOfLineNo
输出是
LINE_NO E_FIELD F_FIELD G_FIELD HSA_STATUS FAMILY CACHE_FAMILY CountOfLineNo TotalOfLineNo Percentage
23053B 00000 00000 00000 S SUMMIT WER 43 199 21.608040201005%