# 4.2. Hàm toán học

### <span style="color: rgb(0, 0, 0);"><span style="mso-list: Ignore;">4.2.1.<span style="font: 7.0pt 'Times New Roman';"> </span></span>ABS</span>

<span style="color: rgb(0, 0, 0);">Tính giá trị tuyệt đối của một biểu thức số.</span>

**<span style="color: rgb(0, 0, 0);">Cú pháp:</span>**

<span style="color: rgb(0, 0, 0);">**ABS** (truong\_du\_lieu\_so Số)<span style="mso-spacerun: yes;"> </span>=&gt; Số</span>

<span style="color: rgb(0, 0, 0);"><span style="font-family: Symbol; mso-fareast-font-family: Symbol; mso-bidi-font-family: Symbol; font-weight: normal; mso-bidi-font-weight: bold;"><span style="mso-list: Ignore;">·<span style="font: 7.0pt 'Times New Roman';">  </span></span></span>**truong\_du\_lieu\_so:** Trường dữ liệu dạng số cần tính giá trị tuyệt đối.</span>

**<span style="color: rgb(0, 0, 0);">Ví dụ về</span> <span style="color: rgb(0, 0, 0);">ABS</span>:**

```
SELECT ABS(-10)
-- 10
```

```mysql
SELECT ABS(0)
-- 0
```

### <span style="color: rgb(0, 0, 0);"><span style="mso-list: Ignore;">4.4.2.<span style="font: 7.0pt 'Times New Roman';"> </span></span>ACOS</span>

<span style="color: rgb(0, 0, 0);">Tính arccosine của một biểu thức số.</span>

**<span style="color: rgb(0, 0, 0);">Cú pháp:</span>**

<span style="color: rgb(0, 0, 0);">**ACOS** (truong\_du\_lieu\_so Số)<span style="mso-spacerun: yes;"> </span>=&gt; DOUBLE</span>

<span style="color: rgb(0, 0, 0);"><span style="font-family: Symbol; mso-fareast-font-family: Symbol; mso-bidi-font-family: Symbol; font-weight: normal; mso-bidi-font-weight: bold;"><span style="mso-list: Ignore;">·<span style="font: 7.0pt 'Times New Roman';">  </span></span></span>**truong\_du\_lieu\_so:** Số có đơn vị là radians và kiểu dữ liệu dạng số.</span>

**<span style="color: rgb(0, 0, 0);">Ví dụ về</span> <span style="color: rgb(0, 0, 0);">ACOS</span>:**

```mysql
SELECT ACOS(0)
-- 1.5707963267948966
```

```mysql
SELECT ACOS(1.0)
-- 0
```

```mysql
SELECT ACOS(-1)
-- 3.141592653589793
```

### <span style="color: rgb(0, 0, 0);"><span style="mso-list: Ignore;">4.2.3.<span style="font: 7.0pt 'Times New Roman';"> </span></span>ADD</span>

<span style="color: rgb(0, 0, 0);">Tính giá trị của phép cộng giữa hai trường dữ liệu dạng số hoặc một trường dữ liệu và một số.</span>

<span style="color: rgb(0, 0, 0);">**Cú pháp:**</span>

<span style="color: rgb(0, 0, 0);">**ADD** (truong\_du\_lieu\_so\_1 Số, truong\_du\_lieu\_so\_2 Số) =&gt; Số</span>

<span style="color: rgb(0, 0, 0);">**<span style="font-family: Symbol;"><span style="mso-list: Ignore;">·<span style="font-style: normal; font-variant: normal; font-kerning: auto; font-optical-sizing: auto; font-feature-settings: normal; font-variation-settings: normal; font-stretch: normal; font-size: 7pt; line-height: normal; font-family: 'Times New Roman';"> </span></span></span>truong\_du\_lieu\_so\_1:** DOUBLE, INTEGER, BIGINT, DECIMAL, hoặc FLOAT.</span>

<span style="color: rgb(0, 0, 0);">**<span style="font-family: Symbol;"><span style="mso-list: Ignore;">·<span style="font-style: normal; font-variant: normal; font-kerning: auto; font-optical-sizing: auto; font-feature-settings: normal; font-variation-settings: normal; font-stretch: normal; font-size: 7pt; line-height: normal; font-family: 'Times New Roman';"> </span></span></span>truong\_du\_lieu\_so\_2:** DOUBLE, INTEGER, BIGINT, DECIMAL, hoặc FLOAT.</span>

<span style="color: rgb(0, 0, 0);">**Ví dụ về ADD với dữ liệu số :**</span>

```mysql
Select ADD(2, 3)
-- 6
```

<span style="color: rgb(0, 0, 0);">**Ví dụ về ADD cột "col" có hai giá trị \[2,3,4\]:**</span>

```mysql
Select ADD(col, 3)
-- 5
-- 6
-- 7
```

### <span style="color: rgb(0, 0, 0);"><span style="mso-list: Ignore;">4.2.4.<span style="font: 7.0pt 'Times New Roman';"> </span></span>ASIN</span>

<span style="color: rgb(0, 0, 0);">Tính arcsine của một biểu thức số.</span>

<span style="color: rgb(0, 0, 0);">**Cú pháp:**</span>

<span style="color: rgb(0, 0, 0);">**ASIN** (truong\_du\_lieu\_so Số)<span style="mso-spacerun: yes;"> </span>=&gt; DOUBLE</span>

<span style="color: rgb(0, 0, 0);">**<span style="font-family: Symbol;"><span style="mso-list: Ignore;">·<span style="font-style: normal; font-variant: normal; font-kerning: auto; font-optical-sizing: auto; font-feature-settings: normal; font-variation-settings: normal; font-stretch: normal; font-size: 7pt; line-height: normal; font-family: 'Times New Roman';"> </span></span></span>truong\_du\_lieu\_so:** Số có đơn vị là radians và kiểu dữ liệu dạng số.</span>

<span style="color: rgb(0, 0, 0);">**Ví dụ về Asin:**</span>

```mysql
SELECT ASIN(0)
-- 0.0
```

```mysql
SELECT ASIN(1)
-- 1.5707963267948966
```

```mysql
SELECT ASIN(-1)
-- -1.5707963267948966
```

### <span style="color: rgb(0, 0, 0);"><span style="mso-list: Ignore;">4.2.5.<span style="font: 7.0pt 'Times New Roman';"> </span></span>ATAN</span>

<span style="color: rgb(0, 0, 0);">Tính arctang của một biểu thức số.</span>

<span style="color: rgb(0, 0, 0);">**Cú pháp:**</span>

<span style="color: rgb(0, 0, 0);">**ATAN** (truong\_du\_lieu\_so Số)<span style="mso-spacerun: yes;"> </span>=&gt; DOUBLE</span>

<span style="color: rgb(0, 0, 0);">**<span style="font-family: Symbol;"><span style="mso-list: Ignore;">·<span style="font-style: normal; font-variant: normal; font-kerning: auto; font-optical-sizing: auto; font-feature-settings: normal; font-variation-settings: normal; font-stretch: normal; font-size: 7pt; line-height: normal; font-family: 'Times New Roman';"> </span></span></span>truong\_du\_lieu\_so:** Số có đơn vị là radians và kiểu dữ liệu dạng số.</span>

<span style="color: rgb(0, 0, 0);">**Ví dụ về ATAN:**</span>

```mysql
SELECT ATAN(-1)
-- -0.7853981633974483
```

```mysql
SELECT ATAN(19564.7)
-- 1.5707452143321894
```

### <span style="color: rgb(0, 0, 0);"><span style="mso-list: Ignore;">4.2.6.<span style="font: 7.0pt 'Times New Roman';"> </span></span>ATAN2</span>

<span style="color: rgb(0, 0, 0);">Tính arctang của tỷ số giữa hai trường dữ liệu.</span>

<span style="color: rgb(0, 0, 0);">**Cú pháp:**</span>

<span style="color: rgb(0, 0, 0);">**ATAN2** (y Số, x Số)<span style="mso-spacerun: yes;"> </span>=&gt; DOUBLE</span>

<span style="color: rgb(0, 0, 0);">**<span style="font-family: Symbol;"><span style="mso-list: Ignore;">·<span style="font-style: normal; font-variant: normal; font-kerning: auto; font-optical-sizing: auto; font-feature-settings: normal; font-variation-settings: normal; font-stretch: normal; font-size: 7pt; line-height: normal; font-family: 'Times New Roman';"> </span></span></span>y:** Giá trị đầu vào kiểu số thực đại diện cho tọa độ y, nằm trong khoảng từ âm vô cùng đến dương vô cùng.</span>

<span style="color: rgb(0, 0, 0);">**<span style="font-family: Symbol;"><span style="mso-list: Ignore;">·<span style="font-style: normal; font-variant: normal; font-kerning: auto; font-optical-sizing: auto; font-feature-settings: normal; font-variation-settings: normal; font-stretch: normal; font-size: 7pt; line-height: normal; font-family: 'Times New Roman';"> </span></span></span>x:** Giá trị đầu vào kiểu số thực đại diện cho tọa độ x, nằm trong khoảng từ âm vô cùng đến dương vô cùng.</span>

<span style="color: rgb(0, 0, 0);">**Ví dụ về ATAN2:**</span>

```mysql
SELECT ATAN2(1,0)
-- 1.5707452143321894
```

```mysql
SELECT ATAN2(0.0,1.0)
-- 0
```

```mysql
SELECT ATAN2(0.0,-1.0)
-- 3.141592653589793
```

```mysql
SELECT ATAN2(-0.00000000001,-1.0)
-- -3.141592653579793
```

### <span style="color: rgb(0, 0, 0);"><span style="mso-list: Ignore;">4.2.7.<span style="font: 7.0pt 'Times New Roman';"> </span></span>CBRT</span>

<span style="color: rgb(0, 0, 0);">Tính căn bậc 3 của các hàng trong một trường dữ liệu.</span>

<span style="color: rgb(0, 0, 0);">**Cú pháp:**</span>

<span style="color: rgb(0, 0, 0);">**CBRT** (truong\_du\_lieu\_so Số)<span style="mso-spacerun: yes;"> </span>=&gt; DOUBLE</span>

<span style="color: rgb(0, 0, 0);">**<span style="font-family: Symbol;"><span style="mso-list: Ignore;">·<span style="font-style: normal; font-variant: normal; font-kerning: auto; font-optical-sizing: auto; font-feature-settings: normal; font-variation-settings: normal; font-stretch: normal; font-size: 7pt; line-height: normal; font-family: 'Times New Roman';"> </span></span></span>truong\_du\_lieu\_so:** trường dữ liệu dạng số cần tính căn bậc 3.</span>

<span style="color: rgb(0, 0, 0);">**Ví dụ về CBRT:**</span>

```mysql
SELECT CBRT(5)
-- 1.709975946676697

```

```mysql
SELECT CBRT(120)
-- 4.932424148653812

```

```mysql
SELECT CBRT(99.5)
-- 4.638049208321277

```

### <span style="color: rgb(0, 0, 0);"><span style="mso-list: Ignore;">4.2.8.<span style="font: 7.0pt 'Times New Roman';"> </span></span>CEIL</span>

<span style="color: rgb(0, 0, 0);">Trả về giá trị bằng hoặc lớn hơn gần nhất nếu là số thập phân của các hàng trong trường dữ liệu đầu vào.</span>

<span style="color: rgb(0, 0, 0);">**Cú pháp:**</span>

<span style="color: rgb(0, 0, 0);"><span style="mso-spacerun: yes;"> </span>**CEIL** (truong\_du\_lieu\_so Số)<span style="mso-spacerun: yes;"> </span>=&gt; INT</span>

<span style="color: rgb(0, 0, 0);">**Ví dụ về CEIL:**</span>

```mysql
SELECT CEIL(37.775420706711)
-- 38

```

```mysql
SELECT CEIL(3.1459)
-- 4

```

```mysql
SELECT CEIL(-37.775420706711)
-- -37

```

```mysql
SELECT CEIL(0)
-- 0

```

### <span style="color: rgb(0, 0, 0);"><span style="mso-list: Ignore;">4.2.9.<span style="font: 7.0pt 'Times New Roman';"> </span></span>COS</span>

<span style="color: rgb(0, 0, 0);">Tính cosine của một biểu thức số.</span>

<span style="color: rgb(0, 0, 0);">**Cú pháp:** </span>

<span style="color: rgb(0, 0, 0);">**COS** (truong\_du\_lieu\_so Số)<span style="mso-spacerun: yes;"> </span>=&gt; DOUBLE</span>

<span style="color: rgb(0, 0, 0);"><span style="font-family: Symbol; mso-fareast-font-family: Symbol; mso-bidi-font-family: Symbol; font-weight: normal; mso-bidi-font-weight: bold;"><span style="mso-list: Ignore;">·<span style="font: 7.0pt 'Times New Roman';"> </span></span></span>**truong\_du\_lieu\_so:** Số có đơn vị là radians và kiểu dữ liệu dạng số.</span>

<span style="color: rgb(0, 0, 0);"> **Ví dụ về COS:**</span>

```mysql
SELECT COS(0)
-- 1.0

```

```mysql
SELECT COS(1.0)
-- 0.5403023058681398

```

```mysql
SELECT COS(-1)
-- 0.5403023058681398

```

### <span style="color: rgb(0, 0, 0);"><span style="mso-list: Ignore;">4.2.10. </span>COSH</span>

<span style="color: rgb(0, 0, 0);">Tính hyperbolic cosine của một biểu thức số.</span>

<span style="color: rgb(0, 0, 0);">**Cú pháp:**</span>

<span style="color: rgb(0, 0, 0);">**COSH** (truong\_du\_lieu\_so Số)<span style="mso-spacerun: yes;"> </span>=&gt; DOUBLE</span>

<span style="color: rgb(0, 0, 0);"><span style="font-family: Symbol; mso-fareast-font-family: Symbol; mso-bidi-font-family: Symbol; font-weight: normal; mso-bidi-font-weight: bold;"><span style="mso-list: Ignore;">·<span style="font: 7.0pt 'Times New Roman';"> </span></span></span>**truong\_du\_lieu\_so:** Số có đơn vị là radians và kiểu dữ liệu dạng số.</span>

<span style="color: rgb(0, 0, 0);">**Ví dụ về COSH:**</span>

```mysql
SELECT COSH(0)
-- 1.0

```

```mysql
SELECT COSH(1.0)
-- 1.543080634815244

```

```mysql
SELECT COSH(-1)
-- 1.543080634815244

```


### <span style="color: rgb(0, 0, 0);"><span style="mso-list: Ignore;">4.2.11. </span>COT</span>

<span style="color: rgb(0, 0, 0);">Tính cotang của một biểu thức số.</span>

**<span style="color: rgb(0, 0, 0);">Cú pháp:</span>**

<span style="color: rgb(0, 0, 0);">**COT** (truong\_du\_lieu\_so Số)<span style="mso-spacerun: yes;"> </span>=&gt; DOUBLE</span>

<span style="color: rgb(0, 0, 0);"><span style="font-family: Symbol; mso-fareast-font-family: Symbol; mso-bidi-font-family: Symbol; font-weight: normal; mso-bidi-font-weight: bold;"><span style="mso-list: Ignore;">·<span style="font: 7.0pt 'Times New Roman';"> </span></span></span>**truong\_du\_lieu\_so:** Số có đơn vị là radians và kiểu dữ liệu dạng số.</span>

<span style="color: rgb(0, 0, 0);">**Ví dụ về COT:**</span>

```mysql
SELECT COT(0)
-- 1.0

```

```mysql
SELECT COT(1.0)
-- 0.6420926159343306

```

```mysql
SELECT COT(-1)
-- -0.6420926159343306

```


### <span style="color: rgb(0, 0, 0);"><span style="mso-list: Ignore;">4.2.12. </span>DEGRESS</span>

<span style="color: rgb(0, 0, 0);">Chuyển đổi đơn vị từ Radians sang Degress (Độ)</span>

**<span style="color: rgb(0, 0, 0);">Cú pháp:</span>**

<span style="color: rgb(0, 0, 0);">**DEGRESS** (truong\_du\_lieu\_so Số)<span style="mso-spacerun: yes;"> </span>=&gt; DOUBLE</span>

<span style="color: rgb(0, 0, 0);"><span style="font-family: Symbol; mso-fareast-font-family: Symbol; mso-bidi-font-family: Symbol; font-weight: normal; mso-bidi-font-weight: bold;"><span style="mso-list: Ignore;">·<span style="font: 7.0pt 'Times New Roman';">  </span></span></span>**truong\_du\_lieu\_so:** Số có đơn vị là radians và có kiểu dữ liệu dạng số.</span>

**<span style="color: rgb(0, 0, 0);">Ví dụ về</span> <span style="color: rgb(0, 0, 0);">DEGRESS</span>:**

```mysql
SELECT DEGRESS(0)
-- 0.0

```

```mysql
SELECT DEGRESS(-1)
-- 57.29577951308232

```

### <span style="color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);"><span style="background-image: initial; background-position: initial; background-size: initial; background-repeat: initial; background-attachment: initial; background-origin: initial; background-clip: initial;"><span style="mso-list: Ignore;">4.2.13. </span></span><span style="background-image: initial; background-position: initial; background-size: initial; background-repeat: initial; background-attachment: initial; background-origin: initial; background-clip: initial;">DIV</span></span>

<span style="color: rgb(0, 0, 0);">Tính kết quả của phép chia giữa hai biểu thức đầu vào</span>

**<span style="color: rgb(0, 0, 0);">Cú pháp:</span>**

<span style="color: rgb(0, 0, 0);">**<span style="mso-spacerun: yes;"> </span>DIV** (truong\_du\_lieu\_so\_1 Số, truong\_du\_lieu\_so\_2 Số)<span style="mso-spacerun: yes;"> </span>=&gt; Số</span>

<span style="color: rgb(0, 0, 0);"><span style="font-family: Symbol; mso-fareast-font-family: Symbol; mso-bidi-font-family: Symbol; font-weight: normal; mso-bidi-font-weight: bold;"><span style="mso-list: Ignore;">·<span style="font: 7.0pt 'Times New Roman';">  </span></span></span>**truong\_du\_lieu\_so\_1:** Số bị chia</span>

<span style="color: rgb(0, 0, 0);"><span style="font-family: Symbol; mso-fareast-font-family: Symbol; mso-bidi-font-family: Symbol; font-weight: normal; mso-bidi-font-weight: bold;"><span style="mso-list: Ignore;">·<span style="font: 7.0pt 'Times New Roman';"> </span></span></span>**truong\_du\_lieu\_so\_2:** Số chia, có thể là một số cụ thể hoặc một trường dữ liệu dạng số.</span>

**<span style="color: rgb(0, 0, 0);">Ví dụ về</span> <span style="color: rgb(0, 0, 0);">DIV</span>:**

```mysql
SELECT DIV(6,2)
-- 3
```

```mysql
SELECT DIV(revenue,order)
-- 3
-- 8
-- 9
```

### <span style="color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);"><span style="background-image: initial; background-position: initial; background-size: initial; background-repeat: initial; background-attachment: initial; background-origin: initial; background-clip: initial;"><span style="mso-list: Ignore;">4.2.14. </span></span><span style="background-image: initial; background-position: initial; background-size: initial; background-repeat: initial; background-attachment: initial; background-origin: initial; background-clip: initial;">DIVIDE</span></span>

<span style="color: rgb(0, 0, 0);">Tính kết quả của phép chia lấy số nguyên giữa hai biểu thức số</span>

**<span style="color: rgb(0, 0, 0);">Cú pháp:</span>**

<span style="color: rgb(0, 0, 0);"><span style="mso-spacerun: yes;"> </span>**DIVIDE** (truong\_du\_lieu\_so\_1 Số, truong\_du\_lieu\_so\_2 Số)<span style="mso-spacerun: yes;"> </span>=&gt; Giá trị dạng số</span>

<span style="color: rgb(0, 0, 0);"><span style="font-family: Symbol; mso-fareast-font-family: Symbol; mso-bidi-font-family: Symbol; font-weight: normal; mso-bidi-font-weight: bold;"><span style="mso-list: Ignore;">·<span style="font: 7.0pt 'Times New Roman';"> </span></span></span>**truong\_du\_lieu\_so\_1:** Số bị chia</span>

<span style="color: rgb(0, 0, 0);"><span style="font-family: Symbol; mso-fareast-font-family: Symbol; mso-bidi-font-family: Symbol; font-weight: normal; mso-bidi-font-weight: bold;"><span style="mso-list: Ignore;">·<span style="font: 7.0pt 'Times New Roman';"> </span></span></span>**truong\_du\_lieu\_so\_2:** Số chia</span>

**<span style="color: rgb(0, 0, 0);">Ví dụ về</span> <span style="color: rgb(0, 0, 0);">DIVIDE</span>:**

```mysql
SELECT DIVIDE(revenue,2)
-- 1
-- 9
-- 20
```

### <span style="color: rgb(0, 0, 0);"><span style="mso-list: Ignore;">4.2.15. </span>EXP</span>

<span style="color: rgb(0, 0, 0);">Tính lũy thừa của số e (cơ số của logarit tự nhiên, xấp xỉ 2.718281...) với số mũ lần lượt là các giá trị trong một trường dữ liệu.</span>

**<span style="color: rgb(0, 0, 0);">Cú pháp:</span>**

<span style="color: rgb(0, 0, 0);">**EXP** (truong\_du\_lieu\_so Số)<span style="mso-spacerun: yes;"> </span>=&gt; DOUBLE</span>

<span style="color: rgb(0, 0, 0);"><span style="font-family: Symbol; mso-fareast-font-family: Symbol; mso-bidi-font-family: Symbol; font-weight: normal; mso-bidi-font-weight: bold;"><span style="mso-list: Ignore;">·<span style="font: 7.0pt 'Times New Roman';"> </span></span></span>**truong\_du\_lieu\_so:** Giá trị số mũ để nâng e lên</span>

**<span style="color: rgb(0, 0, 0);">Ví dụ về</span> <span style="color: rgb(0, 0, 0);">EXP</span>:**

```mysql
SELECT EXP(1)
-- 2.718281828459045
```

```mysql
SELECT EXP(10.0)
-- 22026.465794806718
```

### <span style="color: rgb(0, 0, 0);"><span style="mso-list: Ignore;">4.2.16. </span>FACTORIAL</span>

<span style="color: rgb(0, 0, 0);">Tính giai thừa của một giá trị số.</span>

**<span style="color: rgb(0, 0, 0);">Cú pháp:</span>**

<span style="color: rgb(0, 0, 0);"><span style="mso-spacerun: yes;"> **FACTORIAL** </span>(gia\_tri INT)<span style="mso-spacerun: yes;"> </span>=&gt; BIGINT</span>

<span style="color: rgb(0, 0, 0);"><span style="font-family: Symbol; mso-fareast-font-family: Symbol; mso-bidi-font-family: Symbol; font-weight: normal; mso-bidi-font-weight: bold;"><span style="mso-list: Ignore;">·<span style="font: 7.0pt 'Times New Roman';"> </span></span></span>**gia\_tri:** Giá trị số nguyên từ 0- 20 trong một trường dữ liệu.</span>

**<span style="color: rgb(0, 0, 0);">Ví dụ về</span> <span style="color: rgb(0, 0, 0);"><span style="mso-spacerun: yes;">FACTORIAL</span></span>:**

```mysql
SELECT FACTORIAL(5)
-- 120
```

```mysql
SELECT FACTORIAL(20)
-- 2432902008176640000
```

### <span style="color: rgb(0, 0, 0);"><span style="mso-list: Ignore;">4.2.17. </span>FLOOR</span>

<span style="color: rgb(0, 0, 0);">Trả về giá trị bằng hoặc nhỏ hơn gần nhất nếu là số thập phân của trường dữ liệu đầu vào.</span>

**<span style="color: rgb(0, 0, 0);">Cú pháp:</span>**

<span style="color: rgb(0, 0, 0);"><span style="mso-spacerun: yes;"> </span>**FLOOR** (truong\_du\_lieu\_so Số)<span style="mso-spacerun: yes;"> </span>=&gt; INT</span>

<span style="color: rgb(0, 0, 0);"><span style="font-family: Symbol; mso-fareast-font-family: Symbol; mso-bidi-font-family: Symbol; font-weight: normal; mso-bidi-font-weight: bold;"><span style="mso-list: Ignore;">·<span style="font: 7.0pt 'Times New Roman';"> </span></span></span>**truong\_du\_lieu\_so:** Giá trị số lớn hơn 0</span>

**<span style="color: rgb(0, 0, 0);">Ví dụ về</span> <span style="color: rgb(0, 0, 0);">FLOOR</span>:**

```mysql
SELECT FLOOR(0)
-- 0
```

```mysql
SELECT CEIL(45.76)
-- 45
```

```mysql
SELECT FLOOR(-1.3)
-- -2
```

### <span style="color: rgb(0, 0, 0);"><span style="mso-list: Ignore;">4.2.18. </span>LOG</span>

<span style="color: rgb(0, 0, 0);">Tính logarit tự nhiên<span style="mso-tab-count: 1;"> </span> của các giá trị trong một trường dữ liệu.</span>

**<span style="color: rgb(0, 0, 0);">Cú pháp:</span>**

<span style="color: rgb(0, 0, 0);"><span style="mso-spacerun: yes;"> </span>**LOG** (truong\_du\_lieu\_so Số)<span style="mso-spacerun: yes;"> </span>=&gt; DOUBLE</span>

<span style="color: rgb(0, 0, 0);"><span style="font-family: Symbol; mso-fareast-font-family: Symbol; mso-bidi-font-family: Symbol; font-weight: normal; mso-bidi-font-weight: bold;"><span style="mso-list: Ignore;">·<span style="font: 7.0pt 'Times New Roman';"> </span></span></span>**truong\_du\_lieu\_so:** Giá trị số lớn hơn 0.</span>

**<span style="color: rgb(0, 0, 0);">Ví dụ về</span> <span style="color: rgb(0, 0, 0);">LOG</span>:**

```mysql
SELECT LOG(0)
-- null
```

```mysql
SELECT LOG(1)
-- 0
```

```mysql
SELECT LOG(5)
-- 1.6094379124341003
```

### <span style="mso-list: Ignore;">4.2.19. </span><span style="color: rgb(0, 0, 0); text-indent: 0in;">LOG10</span>

<span style="color: rgb(0, 0, 0);">Tính logarit cơ số 10 của trường dữ liệu đầu vào dạng số.</span>

**<span style="color: rgb(0, 0, 0);">Cú pháp:</span>**

<span style="color: rgb(0, 0, 0);"><span style="mso-spacerun: yes;"> </span>**LOG10** (truong\_du\_lieu\_so Số)<span style="mso-spacerun: yes;"> </span>=&gt; Giá trị dạng số</span>

<span style="color: rgb(0, 0, 0);"><span style="font-family: Symbol; mso-fareast-font-family: Symbol; mso-bidi-font-family: Symbol; font-weight: normal; mso-bidi-font-weight: bold;"><span style="mso-list: Ignore;">·<span style="font: 7.0pt 'Times New Roman';"> </span></span></span>**truong\_du\_lieu\_so:** Giá trị số lớn hơn 0.</span>

**<span style="color: rgb(0, 0, 0);">Ví dụ về</span> <span style="color: rgb(0, 0, 0);">LOG10</span>:**

```mysql
SELECT LOG10(20.5)
-- 1.3117538610557542
```

```mysql
SELECT LOG10(100)
-- 2.0
```

### <span style="color: rgb(0, 0, 0);"><span style="mso-list: Ignore;">4.2.20. </span>LOG1P</span>

<span style="color: rgb(0, 0, 0);">Tính logarit tự nhiên của 1 cộng một giá trị trong trường dữ liệu dạng số.</span>

**<span style="color: rgb(0, 0, 0);">Cú pháp:</span>**

<span style="color: rgb(0, 0, 0);"><span style="mso-spacerun: yes;"> </span>**LOG1P** (truong\_du\_lieu\_so Số)<span style="mso-spacerun: yes;"> </span>=&gt; Giá trị dạng số</span>

<span style="color: rgb(0, 0, 0);"><span style="font-family: Symbol; mso-fareast-font-family: Symbol; mso-bidi-font-family: Symbol; font-weight: normal; mso-bidi-font-weight: bold;"><span style="mso-list: Ignore;">·<span style="font: 7.0pt 'Times New Roman';"> </span></span></span>**truong\_du\_lieu\_so:** Giá trị số lớn hơn -1.</span>

<span style="color: rgb(0, 0, 0);">**Ví dụ về LOG1P**</span>

```mysql
SELECT LOG1P(0)
-- 0

```

```mysql
SELECT LOG1P(0.6931471805599453)
-- 0

```

```mysql
SELECT LOG1P(5)
-- 1.791759469228055

```

### <span style="color: rgb(0, 0, 0);"><span style="mso-list: Ignore;">4.2.21. </span>MULTIPLY</span>

<span style="color: rgb(0, 0, 0);">Tính kết quả của phép nhân giữa các dòng trong hai trường dữ liệu dạng số.</span>

**<span style="color: rgb(0, 0, 0);">Cú pháp:</span>**

<span style="color: rgb(0, 0, 0);">**MULTIPLY** (truong\_du\_lieu\_so Số)<span style="mso-spacerun: yes;"> </span>=&gt; Giá trị dạng số</span>

<span style="color: rgb(0, 0, 0);"><span style="font-family: Symbol; mso-fareast-font-family: Symbol; mso-bidi-font-family: Symbol; font-weight: normal; mso-bidi-font-weight: bold;"><span style="mso-list: Ignore;">·<span style="font: 7.0pt 'Times New Roman';"> </span></span></span>**truong\_du\_lieu\_so:** Giá trị của biểu thức muốn tính logarit.</span>

**<span style="color: rgb(0, 0, 0);">Ví dụ về</span> <span style="color: rgb(0, 0, 0);">MULTIPLY</span>:**

```mysql
SELECT MULTIPLY(10,2)
-- 20

```

```mysql
SELECT MULTIPLY(-2.0,2.0)
-- -4.0

```

```mysql
SELECT MULTIPLY(0,2)
-- 0

```

### <span style="color: rgb(0, 0, 0);"><span style="mso-list: Ignore;">4.2.22. </span>RADIANS</span>

<span style="color: rgb(0, 0, 0);">Chuyển đổi đơn vị từ Degress (Độ) sang Radians</span>

**<span style="color: rgb(0, 0, 0);">Cú pháp:</span>**

<span style="color: rgb(0, 0, 0);">**RADIANS** (x Số)<span style="mso-spacerun: yes;"> </span>=&gt; DOUBLE</span>

<span style="color: rgb(0, 0, 0);"><span style="font-family: Symbol; mso-fareast-font-family: Symbol; mso-bidi-font-family: Symbol; font-weight: normal; mso-bidi-font-weight: bold;"><span style="mso-list: Ignore;">·<span style="font: 7.0pt 'Times New Roman';">  </span></span></span>**x:** Số có đơn vị là degress và kiểu dữ liệu là DOUBLE, INTEGER, BIGINT, DECIMAL, hoặc FLOAT.</span>

**<span style="color: rgb(0, 0, 0);">Ví dụ về</span> <span style="color: rgb(0, 0, 0);">RADIANS</span>:**

```mysql
SELECT RADIANS(45)
-- 0.7853981633974483

```

### <span style="color: rgb(0, 0, 0);"><span style="mso-list: Ignore;">4.2.23. </span>ROUND</span>

<span style="color: rgb(0, 0, 0);">Trả về giá trị sau khi làm tròn cho các giá trị đầu vào. Nếu không nhập số lượng chữ số thập phân số nguyên gần nhất sẽ được trả về.</span>

**<span style="color: rgb(0, 0, 0);">Cú pháp:</span>**

<span style="color: rgb(0, 0, 0);">**ROUND** (truong\_du\_lieu\_so Số, Gia\_tri INT)<span style="mso-spacerun: yes;"> </span>=&gt; Số</span>

<span style="color: rgb(0, 0, 0);"><span style="font-family: Symbol; mso-fareast-font-family: Symbol; mso-bidi-font-family: Symbol; font-weight: normal; mso-bidi-font-weight: bold;"><span style="mso-list: Ignore;">·<span style="font: 7.0pt 'Times New Roman';"> </span></span></span>**truong\_du\_lieu\_so:** Số cần làm tròn.</span>

<span style="color: rgb(0, 0, 0);"><span style="font-family: Symbol; mso-fareast-font-family: Symbol; mso-bidi-font-family: Symbol; font-weight: normal; mso-bidi-font-weight: bold;"><span style="mso-list: Ignore;">·<span style="font: 7.0pt 'Times New Roman';"> </span></span></span>**gia\_tri:** Số lượng chữ số ở phần thập phân.</span>

**<span style="color: rgb(0, 0, 0);">Ví dụ về</span> <span style="color: rgb(0, 0, 0);">ROUND</span>:**

```mysql
SELECT ROUND(24,0)
-- 24

```

```mysql
SELECT ROUND(24,-2)
-- 0

```

```mysql
SELECT ROUND(24.35,1)
-- 24.4

```

### <span style="color: rgb(0, 0, 0);"><span style="mso-list: Ignore;">4.2.24. </span>SIN</span>

<span style="color: rgb(0, 0, 0);">Tính sine của một biểu thức số.</span>

**<span style="color: rgb(0, 0, 0);">Cú pháp:</span>**

<span style="color: rgb(0, 0, 0);">**SIN** (truong\_du\_lieu\_so Số)<span style="mso-spacerun: yes;"> </span>=&gt; DOUBLE</span>

<span style="color: rgb(0, 0, 0);"><span style="font-family: Symbol; mso-fareast-font-family: Symbol; mso-bidi-font-family: Symbol; font-weight: normal; mso-bidi-font-weight: bold;"><span style="mso-list: Ignore;">·<span style="font: 7.0pt 'Times New Roman';"> </span></span></span>**truong\_du\_lieu\_so:** Số có đơn vị là radians và kiểu dữ liệu là DOUBLE, INTEGER, DECIMAL, hoặc FLOAT.</span>

**<span style="color: rgb(0, 0, 0);">Ví dụ về</span> <span style="color: rgb(0, 0, 0);">SIN</span>:**

```mysql
SELECT SIN(360)
-- 0.9589157234143065

```

```mysql
SELECT SIN(510.89)
-- 0.9282211721815067

```

```mysql
SELECT SIN(-1)
-- -0.8414709848078965

```

### <span style="color: rgb(0, 0, 0);"><span style="mso-list: Ignore;">4.2.25. </span>SINH</span>

<span style="color: rgb(0, 0, 0);">Tính hyperbolic sine của một biểu thức số.</span>

**<span style="color: rgb(0, 0, 0);">Cú pháp:</span>**

<span style="color: rgb(0, 0, 0);">**SINH** (truong\_du\_lieu\_so Số)<span style="mso-spacerun: yes;"> </span>=&gt; DOUBLE</span>

<span style="color: rgb(0, 0, 0);"><span style="font-family: Symbol; mso-fareast-font-family: Symbol; mso-bidi-font-family: Symbol; font-weight: normal; mso-bidi-font-weight: bold;"><span style="mso-list: Ignore;">·<span style="font: 7.0pt 'Times New Roman';"> </span></span></span>**truong\_du\_lieu\_so:** Số có đơn vị là radians và kiểu dữ liệu dạng số.</span>

<span style="line-height: 115%; color: rgb(0, 0, 0);"> <span style="color: rgb(0, 0, 0);">**Ví dụ về**</span> **<span style="color: rgb(0, 0, 0);">SINH</span>:**</span>

```mysql
SELECT SINH(1)
-- 1.1752011936438014

```

```mysql
SELECT SINH(1.5)
-- 2.1292794550948173

```

### <span style="color: rgb(0, 0, 0);"><span style="mso-list: Ignore;">4.2.26. </span>SQRT</span>

<span style="color: rgb(0, 0, 0);">Tính căn bậc hai của trường dữ liệu dạng số không âm.</span>

**<span style="color: rgb(0, 0, 0);">Cú pháp:</span>**

<span style="color: rgb(0, 0, 0);">**SQRT** (truong\_du\_lieu\_so Số)<span style="mso-spacerun: yes;"> </span>=&gt; DOUBLE </span>

<span style="color: rgb(0, 0, 0);"><span style="font-family: Symbol; mso-fareast-font-family: Symbol; mso-bidi-font-family: Symbol; font-weight: normal; mso-bidi-font-weight: bold;"><span style="mso-list: Ignore;">·<span style="font: 7.0pt 'Times New Roman';"> </span></span></span>**truong\_du\_lieu\_so:** Trường dữ liệu cần tính căn bậc hai</span>

**<span style="color: rgb(0, 0, 0);">Ví dụ về</span> <span style="color: rgb(0, 0, 0);">SQRT</span>:**

```mysql
SELECT (25.25)
-- 5.024937810560445

```

```mysql
SELECT (25)
-- 5.0

```

#### <span style="line-height: 115%; color: rgb(0, 0, 0);"> </span>

### <span style="color: rgb(0, 0, 0);"><span style="mso-list: Ignore;">4.2.26. </span>SUBTRACT</span>

<span style="color: rgb(0, 0, 0);">Tính kết quả của phép trừ giữa các dòng trong hai trường dữ liệu dạng số.</span>

**<span style="color: rgb(0, 0, 0);">Cú pháp:</span>**

<span style="color: rgb(0, 0, 0);">**SUBTRACT** (truong\_du\_lieu\_so Số, so\_tru Số)<span style="mso-spacerun: yes;"> </span>=&gt; Giá trị dạng số</span>

<span style="color: rgb(0, 0, 0);"><span style="font-family: Symbol; mso-fareast-font-family: Symbol; mso-bidi-font-family: Symbol; font-weight: normal; mso-bidi-font-weight: bold;"><span style="mso-list: Ignore;">·<span style="font: 7.0pt 'Times New Roman';"> </span></span></span>**truong\_du\_lieu\_so:** Giá trị của trường dữ liệu được coi như số bị trừ.</span>

<span style="color: rgb(0, 0, 0);"><span style="font-family: Symbol; mso-fareast-font-family: Symbol; mso-bidi-font-family: Symbol; font-weight: normal; mso-bidi-font-weight: bold;"><span style="mso-list: Ignore;">·<span style="font: 7.0pt 'Times New Roman';"> </span></span></span>**so\_tru:** Số trừ, có thể là một trường dữ liệu dạng số hoặc một số cụ thể</span>

**<span style="color: rgb(0, 0, 0);">Ví dụ về</span> <span style="color: rgb(0, 0, 0);">SUBTRACT</span>:**

```mysql
SELECT SUBTRACT (10,2)
-- 8

```

```mysql
SELECT SUBTRACT (-2.0,2.0)
-- -4.0

```

```mysql
SELECT SUBTRACT(0,2)
-- -2

```

### <span style="color: rgb(0, 0, 0);"><span style="mso-list: Ignore;">4.2.28. </span>TAN</span>

<span style="color: rgb(0, 0, 0);">Tính tang của một biểu thức số.</span>

**<span style="color: rgb(0, 0, 0);">Cú pháp:</span>**

<span style="color: rgb(0, 0, 0);">**TAN** (truong\_du\_lieu\_so Số)<span style="mso-spacerun: yes;"> </span>=&gt; DOUBLE</span>

<span style="color: rgb(0, 0, 0);"><span style="font-family: Symbol; mso-fareast-font-family: Symbol; mso-bidi-font-family: Symbol; font-weight: normal; mso-bidi-font-weight: bold;"><span style="mso-list: Ignore;">·<span style="font: 7.0pt 'Times New Roman';"> </span></span></span>**truong\_du\_lieu\_so:** Số có đơn vị là radians và kiểu dữ liệu là DOUBLE, INTEGER, DECIMAL, hoặc FLOAT</span>

**<span style="color: rgb(0, 0, 0);">Ví dụ về</span> <span style="color: rgb(0, 0, 0);">TAN</span>:**

```mysql
SELECT TAN(180.8)
-- -6.259341891872157

```

```mysql
SELECT TAN(1200)
-- -0.08862461268886584

```

### <span style="color: rgb(0, 0, 0);"><span style="mso-list: Ignore;">4.2.29. </span>TANH</span>

<span style="color: rgb(0, 0, 0);">Tính hyperbolic tang của một biểu thức số.</span>

**<span style="color: rgb(0, 0, 0);">Cú pháp:</span>**

<span style="color: rgb(0, 0, 0);">**TANH** (truong\_du\_lieu\_so Số)<span style="mso-spacerun: yes;"> </span>=&gt; DOUBLE</span>

<span style="color: rgb(0, 0, 0);"><span style="font-family: Symbol; mso-fareast-font-family: Symbol; mso-bidi-font-family: Symbol; font-weight: normal; mso-bidi-font-weight: bold;"><span style="mso-list: Ignore;">·<span style="font: 7.0pt 'Times New Roman';">  </span></span></span>**truong\_du\_lieu\_so:** Số có đơn vị là radians và kiểu dữ liệu là: DOUBLE, INTEGER, BIGINT, DECIMAL, hoặc FLOAT.</span>

<span style="line-height: 115%; color: rgb(0, 0, 0);"> <span style="color: rgb(0, 0, 0);">**Ví dụ về**</span> **TANH:**</span>

```mysql
SELECT TANH(1.5)
-- 0.9051482536448664

```

```mysql
SELECT TANH(1)
-- 0.7615941559557649

```