# What Is Number Data Type in Snowflake?

//

Scott Campbell

What Is Number Data Type in Snowflake?

In Snowflake, the number data type is used to store numeric values. It is a versatile data type that can accommodate various types of numbers, including integers and decimals.

## Integer Numbers

An integer number is a whole number without any decimal places. Snowflake supports both positive and negative integer values. You can use the number data type to store integers of different sizes, such as smallint, integer, or bigint.

Example:

```CREATE TABLE employees (
employee_id   NUMBER(6),
employee_name VARCHAR(50),
);
```

In the above example, the employee_id column is defined as NUMBER(6), which means it can store integer values up to 6 digits in length.

## Decimal Numbers

A decimal number is a real number that includes decimal places. Snowflake provides different precisions and scales for storing decimal numbers using the NUMBER data type.

### Precision and Scale

The precision refers to the total number of digits in a decimal number, including both the whole part and the decimal part. The scale represents the number of digits after the decimal point.

Example:

```CREATE TABLE products (
product_id   NUMBER(10),
price        NUMBER(10, 2)
);
```

In this example, product_id column has a precision of 10, which means it can store numbers with up to 10 digits. The price column has a precision of 10 and a scale of 2, allowing it to store numbers with up to two decimal places.

## Performing Mathematical Operations

The number data type in Snowflake allows you to perform various mathematical operations, such as addition, subtraction, multiplication, and division. You can use these operations in SQL queries to manipulate numeric values stored in the number data type.

Example:

```SELECT price * 0.1 AS discount_price
FROM products;
```

In this example, the SQL query calculates the discounted price by multiplying the price column by 0.1.

## Conclusion

The number data type in Snowflake is a powerful tool for storing and manipulating numeric values. Whether you need to store integers or decimal numbers, Snowflake provides the flexibility to define the precision and scale according to your requirements. By utilizing the number data type effectively, you can perform mathematical calculations and retrieve accurate results in your Snowflake database.