0

我想将小数位更改为 4,但无法弄清楚,求助!

- 询问

select CASE v2.[ie version]
      When '11' Then 'Internet Explorer 11'
      When '9' Then 'Internet Explorer 9'
      When '8' Then 'Internet Explorer 8'
      Else [IE Version] End [IE Version],
COUNT(distinct v1.guid) 'Total Count', COUNT(*) *100.00 / SUM(COUNT(*)) over()'Total Percentage' from vcomputer v1
inner join vIEVersions v2 on v1.guid = v2.guid where v1.ismanaged = '1'
and v2.[IE Version] is not Null and v2.[IE Version] not in ('Unknown', '7', '10')
group by v2.[IE Version] order by 1 desc

- 输出

IE Version               Total Count    Total Percentage
Internet Explorer 9      180            1.7349397590361
Internet Explorer 8      531            5.1180722891566
Internet Explorer 11     9664           93.1469879518072
4

3 回答 3

0

我认为首先你必须首先CREATE TABLE VIEW进行小数百分比细分,然后调用 round 函数的总和值,如下例代码:

SELECT ROUND(column_name,decimals) FROM table_name;

希望能帮助到你。

于 2016-06-26T15:41:55.043 回答
0

CAST 到十进制应该足够了:

CAST(COUNT(*) *100.00 / SUM(COUNT(*)) over() as decimal(12,4)) 
于 2016-06-26T16:40:25.843 回答
0

试试这个,例如

声明@i int=23

选择演员(@i*100.00/3 作为十进制(10,4))

于 2016-06-27T05:12:34.213 回答