In SQL, the **number data type** is used to store numeric values. It allows you to store integers and decimal numbers in a database table. Understanding how to work with number data types in SQL is essential for efficient data management and manipulation.

## Types of Number Data Types in SQL

There are several number data types available in SQL, each designed to store different types of numeric values:

__INT__: This represents an integer value, which is a whole number without any decimal places. It typically occupies 4 bytes of storage.__FLOAT__: This represents a floating-point number, which can store both integer and decimal values.It offers a wider range of precision but also takes up more storage space compared to INT.

__DECIMAL__: This represents a fixed-point number with a specific precision and scale. The precision refers to the total number of digits that can be stored, while the scale specifies the maximum number of decimal places.

## Working with Number Data Types

To use number data types effectively in your SQL queries, it’s important to understand how to declare and manipulate them. Here are some common operations:

### 1. Declaring Number Columns

When creating a database table, you need to specify the appropriate number data type for each column that will hold numeric values. For example:

```
CREATE TABLE Employees (
EmployeeID INT,
Salary DECIMAL(10, 2),
Age INT
);
```

In this example, we declare three columns: EmployeeID as an INT, Salary as a DECIMAL with a precision of 10 and scale of 2, and Age as an INT.

### 2. Inserting Number Values

To insert number values into a table, you need to ensure that the values match the defined data type. For example:

```
INSERT INTO Employees (EmployeeID, Salary, Age)
VALUES (1, 50000.00, 30);
```

This statement inserts a new record with an EmployeeID of 1, a Salary of 50000.00 (a decimal value), and an Age of 30.

### 3. Performing Arithmetic Operations

SQL provides various arithmetic operators for performing calculations on number values. Some commonly used operators include:

__+__(addition)__–__(subtraction)__*__(multiplication)__/__(division)

For example, to calculate the total salary of all employees:

```
SELECT SUM(Salary) AS TotalSalary
FROM Employees;
```

### 4. Applying Mathematical Functions

SQL also provides a range of built-in mathematical functions that can be applied to number data types. These functions include:

__SQRT()__: Calculates the square root of a number.__ABS()__: Returns the absolute value of a number.__ROUND()__: Rounds a number to a specified decimal place.

For example, to calculate the average age of employees:

```
SELECT AVG(Age) AS AverageAge
FROM Employees;
```

## Conclusion

The number data type in SQL allows you to store and manipulate numeric values effectively. By understanding the different types of number data types, declaring them correctly, and utilizing arithmetic operations and mathematical functions, you can perform powerful calculations and analysis on your data.

Remember to choose the appropriate number data type based on your requirements to ensure efficient storage and accurate results in your SQL queries.