Sum and split Bigint, results with decimal precision?

I save the value bigint(for file sizes) in a table. I need to group by one column and for filesizes(which are in bytes). I would like to have a column showing their GB. This would mean Sum(FileSize/1024/1024/1024)that it does not show any decimal places. My research shows that this may be due to truncation rather than rounding.

I tried many options castand convert, but can not find any information about sumand dividea bigintand support decimals. If I take the sum and divide it in Excel, I get decimals that tell me that there must be a way in SQL to do this.

Any help is appreciated.

+3
source share
1 answer
Sum(CAST(FileSize AS FLOAT)/1024/1024/1024)
+9
source

Source: https://habr.com/ru/post/1770354/


All Articles