Basic SQL Topics
Huge Numbers
Sometimes, the resulting dataset will return a huge number. In SQL, you may encounter an “Arithmetic Overflow” error and to prevent that, you must convert the result into a “BIGINT”. This is basically ensuring that SQL can handle an extremely large number so that it does not “overflow” during calculations.
SELECT CONVERT( BIGINT, SUM(Population) )
FROM database_table
In the above SQL query, we’re summing the Population and converting it to a BIGINT (a Big Integer in SQL) so that the computer can handle that extremely large value. Most of the time this case will not be encountered, but it’s good to get ahead of it in case that it does and if dealing with data with large numbers.