Revision
3. Numbers – quick revision
So you think you can count
Round and other functions
Revision and practice

Instruction

Before we continue, let's review what we know about numbers already.

Integer numbers are expressed in the normal, intuitive way: 1, 2, 43, -27 etc. Fractions are expressed with a dot (.): 12.45, -401.238, etc. Please note that in some languages you use a comma instead of a dot, but you cannot do it in SQL (12,45 is incorrect)!

In SQL (and in most programming languages) there are three kinds of number types:

  1. integer type - they store integers,
  2. floating point numbers - they store fractions in binary format,
  3. 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
FROM character;

Exercise

For each character, display its name, level and the sum of its hp and mp.

Stuck? Here's a hint!

You can add columns with a plus (+).

Console

Code editor

Result

TableConsole