Before we continue, let's review what we know about numbers already.
Integer numbers are expressed in the normal, intuitive way:
-27 etc. Fractions are expressed with a period (
-401.238, etc. Please note that in some languages you use a comma instead of a period, but you cannot do that in SQL (
12,45 is incorrect)!
In SQL (and in most programming languages) there are three kinds of number types:
- Integer type – they store integers but not fractions.
- Floating point numbers – they store fractions in binary format.
- Decimal numbers – they store fractions in decimal format.
In this part we'll discuss some of the differences between various numeric data types in SQL.
Of course, you can use the four basic mathematical operations:
/ with numbers in SQL. You can also use columns and constant numbers together, for instance:
SELECT hp / 100