当前位置:网站首页>Important SQL server functions - numeric functions
Important SQL server functions - numeric functions
2022-07-28 04:24:00 【Navicat China】
The first 2 part : Number function
Like most modern relational database products ,SQL Server Loaded the set of built-in functions . Although some functions are very similar on the whole , But the exact name and signature may be different . therefore , We'd better review the common SQL Functional SQL Server Specific implementation . In this series of The first 1 part in , We discussed string functions . In today's article , We will continue to discuss numerical functions , This is very useful for generating statistics and calculating values !
ABS
This is not the abdominal muscles that people train for going to the beach . contrary ,ABS yes “Absolute( absolute )” Abbreviation . therefore ,ABS Function takes a numeric value as its argument , And return its absolute equivalent . In simpler terms ,ABS Returns the given number ( Whether it's positive or negative ) Positive form of . This is the function signature :
ABS(inputNumber)
In mathematics and statistics , deviation (deviation) It measures the value of a variable and some other value ( It is usually the mean or average value of the variable ) A measure of the difference . Deviations can be signed or unsigned . The latter is ABS Function will help you solve . Here's a right ClassicModels Query of sample database , The database shows the signed and unsigned credit lines of customers grouped by city ( absolute ) deviation :

ROUND
Another very common numerical function is ROUND. The implementation of rounding functions can be very different . Some are only rounded to integers , Others allow you to specify the number of decimal places to round . and SQL Server Of ROUND Function can accept up to three parameters :
ROUND(number, decimals, operation)
- number: Floating point number to round ( Decimal system )
- decimals: Round the number to the number of decimal places
- operation: Optional parameters that affect the rounding operation . If the value is 0( Or omit ), Then the function performs regular rounding , thus 5 Or a larger number will increase to the next digit . except 0 Any value other than will cause the function to truncate the result to decimal places .
It is very common to round the value of money to two decimal places . This is our previous query with rounded numbers :

CEILING
CEILING The function is similar to ROUND, Except that it is always rounded up to the next integer value . therefore ,25.01 and 25.75 Will be rounded up to 26. This is its grammar :
CEILING(number)
Let's go CEILING Function is applied to our previous query , Round the credit limit to the nearest integer and pass CEILING Compare the filtered credit limit :

FLOOR
FLOOR yes CEILING Opposite side of function ; It always rounds a number to the first integer less than or equal to that number . For positive numbers ,FLOOR Will simply truncate the decimal without changing the next highest integer . however , For negative numbers , It does increment integers down . for example ,-0.5 Of FLOOR yes -1, Because it is less than -0.5 The first integer of .
FLOOR(number)
Without using ABS In the case of FLOOR Function applied to sample queries , Shows its effect on positive and negative numbers :

summary
In today's article , We introduced SQL Server Some of the most important numerical functions of . thereinafter , We will study the date function . If you are right about Navicat for SQL Server Interested in , Free trial 14 God !
Looking back
Navicat Poisoned | The truth is coming !
Equipment paralysis caused by piracy
Navicat 16.1 by OceanBase Community Edition
Navicat Become a member of the database Innovation Laboratory of the Academy of communications
Navicat Academic partnership program - Free education application
Navicat Technology think tank - Practical exercises and answers to various hot questions
Free trial introduction | Navciat 16 Database management tools
边栏推荐
- 网页源代码查看竟然有这么多方法!你都知道吗?
- Adding DSP library to STM32F103 and its solution
- JDBC usage
- 10 more advanced open source command line tools
- Un7.27: how to successfully build a ruoyi framework project in idea?
- The State Administration of market supervision exposes typical cases of food safety
- 功耗:Leakage Power
- Solana's "deceptive behavior": making mobile phones and opening stores
- Machine learning 07: Bayesian learning
- Learn regular expressions (regexp)
猜你喜欢

ServletContext、request、response

C语言初阶——循环语句(while,for,do while)

Go结构体
![[untitled]](/img/e9/4b00244b67af5ddaa3f35baa1ac968.png)
[untitled]

XML file usage and parsing

Kotlin -- function
![[coding and decoding] Huffman coding and decoding based on Matlab GUI [including Matlab source code 1976]](/img/af/27e3794f93166d8ecad9b42dafaf0f.png)
[coding and decoding] Huffman coding and decoding based on Matlab GUI [including Matlab source code 1976]

【无标题】
![[yolov5 practice 5] traffic sign recognition system based on yolov5 -yolov5 integration pyqt5](/img/81/89b8e38801f706ef396943a79ef4c5.png)
[yolov5 practice 5] traffic sign recognition system based on yolov5 -yolov5 integration pyqt5

Fedformer MOE module
随机推荐
Network visualization: features of convolution kernel and CNN visualization (through the attention part of gradient visualization network)
校园流浪猫信息记录和分享的小程序源码
【day03】流程控制语句
Construction and use of FTP server and NFS server
MATLB | location and constant volume IEEE30 node implementation of distributed energy
un7.27:redis数据库常用命令。
【YOLOv5实战5】基于YOLOv5的交通标志识别系统-YOLOv5整合PyQt5
金仓数据库KingbaseES安全指南--5.1. 数据库的传输安全
Solana「迷惑行为」:造手机、开门店
Kingbasees Security Guide for Jincang database -- 4 data access protection
金仓数据库KingbaseES安全指南--4 数据访问保护
The unsatisfied analysis of setup and hold timing is the solution
VAE generation model (with VAE implementation MNIST code)
IPC: multi process binder Aidl user guide, including cases
What technical capabilities should a qualified software testing engineer have?
Fedformer MOE module
openpose的一些个人理解
Domestic high hidden free agent crawler code
Learn regular expressions (regexp)
[untitled]