Deals Of The Week - hours only!Up to 80% off on all courses and bundles.-Close
Reviewing SQL and numbers
3. Numbers – quick review
So you think you can count
Round and other functions
Review 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 period (.): 12.45, -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:

  1. Integer type – they store integers but not fractions.
  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
  • the sum of its hp and mp (name this column sum).

Stuck? Here's a hint!

You can add columns with a plus (+).