Sum and Divide a Bigint, Results with decimal precision?
I am storing a bigint
value (for file sizes) in a table. I need to group on one column and for the filesizes
(which are in bytes). I would like to have a column showing them by GB. This would mean Sum(FileSize/1024/1024/1024)
which is not showing any decimal places. My research seems to indicate this may be due to truncation rather than rounding.
I have tried many options of cast
and convert
, but cannot seem to find any information about how to sum
and divide
a bigint
, and maintain the decimals. If I take the sum and divide it in Excel, I get the decimals, which tells me there has to be 开发者_如何学JAVAa way to do this in SQL.
Any help is appreciated.
Sum(CAST(FileSize AS FLOAT)/1024/1024/1024)
精彩评论