0

I would like to alter the decimal places to 4 but can't figure it out, help!

--Query

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

--Output

IE Version               Total Count    Total Percentage
Internet Explorer 9      180            1.7349397590361
Internet Explorer 8      531            5.1180722891566
Internet Explorer 11     9664           93.1469879518072
Vamsi Prabhala
  • 48,685
  • 4
  • 36
  • 58
user3009669
  • 51
  • 1
  • 8
  • Possible duplicate of [Format number as percent in MS SQL Server](http://stackoverflow.com/questions/30089490/format-number-as-percent-in-ms-sql-server) – TZHX Jun 26 '16 at 15:34

3 Answers3

0

I think that first you have to first CREATE TABLE VIEW of the decimal percentage breakdown and then call the round function the values of the sum like this example code:

SELECT ROUND(column_name,decimals) FROM table_name;

Hope it helps.

0

CAST to decimal should be enough:

CAST(COUNT(*) *100.00 / SUM(COUNT(*)) over() as decimal(12,4)) 
gofr1
  • 15,741
  • 11
  • 42
  • 52
0

try this for example,

declare @i int=23

select cast(@i*100.00/3 as decimal(10,4))

KumarHarsh
  • 5,046
  • 1
  • 18
  • 22