Absolutely right! Here’s the solution breakdown.

## Number types

By default, an SQL engine (the database that runs our queries) wants to keep the numeric type. For example, if you have multiple integers (no decimal point), it’ll give you an integer as a result.

What it really means is that for a database, numbers `100`

and `100.0`

are different – one has a decimal point (a “float” or “numeric” in PostgreSQL), and the other doesn’t have a decimal point (an “integer” number).

Here are a couple of queries you can actually run in the Playground to inspect these types:

```
SELECT pg_typeof(100.0)
```

```
SELECT pg_typeof(100)
```

Note that the `pg_typeof()`

function exists only in PostgreSQL.

## Choosing the number type for your query

There’re a couple of ways we can control the number type in a query’s result set.

If we know upfront that our input numbers are integers and we want an integer in return – nothing to do from our side, the database will take care of everything.

Here’s an example with integers:

```
SELECT 11 / 3
-- 3
```

and an example with decimal numbers:

```
SELECT 9.3 / 3
-- 3.1
```

### Case 2: change integer to decimal

Sometimes (as in your example), we need to change the type. For example, we know that our input numbers are integers, and we want to have a decimal point in our result (like in the example with division ).

We have a couple of options. The easiest – we can multiply our operation by `1.0`

(thus forcing the SQL engine to give us a decimal number in the result set)

```
SELECT 1.0 * 11 / 3
-- 3.6666666
```

or we can convert one number to a decimal:

```
SELECT 11::numeric / 3
-- 3.6666666
```

### Case 3: change decimal to integer

Lastly, we need to report integer numbers, although we’re operating with decimal numbers. In other words, we need to round the result of our query:

```
SELECT ROUND(9.3 / 3)
-- 3
```

Note that the `ROUND()`

function rounds the input to the closest integer:

```
SELECT ROUND(1.4 / 3)
-- 0
```

```
SELECT ROUND(1.5 / 3)
-- 1
```

If you want to force a specific rounding to the higher or lower integer, use the `CEIL()`

and the `FLOOR()`

functions:

```
SELECT CEIL(1.4 / 3)
-- 1
```

```
SELECT FLOOR(1.5 / 3)
-- 0
```