Joe Celko's SQL for Smarties: Advanced SQL Programming, Third Edition

Sql is not A computational or procedural language; the arithmetic capability of SQL is weaker than that of any other language you have ever used. But there are some tricks that you need to know when working with numbers in SQL and when passing them to a host program. Much of the arithmetic and the functions are defined by implementations, so you should experiment with your particular product and make notes on the defaults, precision, and tools in the math library of your database.
You should also read Chapter 21, which deals with the related topic of aggregate functions. This chapter deals with the arithmetic that you would use across a row, instead of down a column; they are not quite the same.
The SQL Standard has a wide range of numeric types. The idea is that any host language can find an SQL numeric type that matches one of its own.
You will also find some vendor extensions in the numeric data types, the most common of which is MONEY. This is really a DECIMAL or NUMERIC data type, which also accepts and displays currency symbols in input and output.
Numbers in SQL are classified as either exact or approximate. An exact numeric value has a precision, p, and a scale, s. The precision is a positive integer that determines the number of significant digits...