sql算术运算符_SQL中的算术运算符
sql算術(shù)運(yùn)算符
SQL | 算術(shù)運(yùn)算符 (SQL | Arithmetic Operators)
Different number-crunching administrators are utilized in SQL to be specific Addition (+), Subtraction (-), Multiplication (*), Division (/), Modulus (%).
SQL中使用了不同的數(shù)字運(yùn)算管理員來表示特定的加法(+),減法(-),乘法(*),除法(/),模數(shù)(%) 。
For the further examples we will be referring to the following base table:
對(duì)于其他示例,我們將參考以下基礎(chǔ)表:
Table: BOOKS
表:書
| 9871 | Nancy Drew | 200 | 5% |
| 9560 | Goosebump | 250 | 10% |
| 9810 | Sherlock Holmes | 300 | 15% |
| 8700 | The Blue Umbrella | 200 | 6% |
| 5086 | Gulliver Travels | 160 | 4% |
| 1272 | Hellen Keller | 150 | 4% |
| 9871 | 南希·德魯 | 200 | 5% |
| 9560 | 雞皮ump | 250 | 10% |
| 9810 | 夏洛克·福爾摩斯 | 300 | 15% |
| 8700 | 藍(lán)傘 | 200 | 6% |
| 5086 | 格列佛游記 | 160 | 4% |
| 1272 | 海倫·凱勒 | 150 | 4% |
1)加法(+) (1) Addition (+))
It is utilized to perform addition procedures on the information things, things incorporate either single section or different segments.
它用于對(duì)信息事物執(zhí)行附加過程,這些事物包含單個(gè)部分或不同的段。
Implementation:
實(shí)現(xiàn)方式:
SELECT bookno, name, cost, discount, cost+50 AS "Final Cost" FROM BOOKS;Output
輸出量
| 9871 | Nancy Drew | 200 | 5% | 250 |
| 9560 | Goosebump | 250 | 10% | 300 |
| 9810 | Sherlock Holmes | 300 | 15% | 350 |
| 8700 | The Blue Umbrella | 200 | 6% | 250 |
| 5086 | Gulliver Travels | 160 | 4% | 210 |
| 1272 | Hellen Keller | 150 | 4% | 200 |
| 9871 | 南希·德魯 | 200 | 5% | 250 |
| 9560 | 雞皮ump | 250 | 10% | 300 |
| 9810 | 夏洛克·福爾摩斯 | 300 | 15% | 350 |
| 8700 | 藍(lán)傘 | 200 | 6% | 250 |
| 5086 | 格列佛游記 | 160 | 4% | 210 |
| 1272 | 海倫·凱勒 | 150 | 4% | 200 |
Similarly, we can do the addition of two columns too.
同樣,我們也可以添加兩列。
2)減法(-) (2) Subtraction (-))
It is utilized to perform subtraction procedures on the information things, things incorporate either a single section or different segments.
它用于對(duì)信息事物執(zhí)行減法過程,信息包含單個(gè)部分或不同的段。
Implementation:
實(shí)現(xiàn)方式:
SELECT bookno, name, cost, discount, cost-discount AS "Final Cost" FROM BOOKS;Output
輸出量
| 9871 | Nancy Drew | 200 | 12.50 | 237.50 |
| 9560 | Goosebump | 250 | 30.00 | 270.00 |
| 9810 | Sherlock Holmes | 300 | 52.50 | 297.50 |
| 8700 | The Blue Umbrella | 200 | 15.00 | 235.00 |
| 5086 | Gulliver Travels | 160 | 8.40 | 201.6 |
| 1272 | Hellen Keller | 150 | 8.00 | 192.00 |
| 9871 | 南希·德魯 | 200 | 12.50 | 237.50 |
| 9560 | 雞皮ump | 250 | 30.00 | 270.00 |
| 9810 | 夏洛克·福爾摩斯 | 300 | 52.50 | 297.50 |
| 8700 | 藍(lán)傘 | 200 | 15.00 | 235.00 |
| 5086 | 格列佛游記 | 160 | 8.40 | 201.6 |
| 1272 | 海倫·凱勒 | 150 | 8.00 | 192.00 |
3)乘法(*) (3) Multiplication (*))
It is utilized to perform multiplication procedures on the information things, things incorporate either a single section or different segments.
它用于對(duì)信息事物執(zhí)行乘法過程,這些事物包含單個(gè)節(jié)或不同段。
Implementation:
實(shí)現(xiàn)方式:
SELECT bookno, name, cost, discount, cost*discount AS "Final Cost" FROM BOOKS;Output
輸出量
| 9871 | Nancy Drew | 200 | 12.50 | ?2500? |
| 9560 | Goosebump | 250 | 30.00 | 7500 |
| 9810 | Sherlock Holmes | 300 | 52.50 | 15750 |
| 8700 | The Blue Umbrella | 200 | 15.00 | 3000 |
| 5086 | Gulliver Travels | 160 | 8.40 | 1344 |
| 1272 | Hellen Keller | 150 | 8.00 | 1200 |
| 9871 | 南希·德魯 | 200 | 12.50 | ?2500? |
| 9560 | 雞皮ump | 250 | 30.00 | 7500 |
| 9810 | 夏洛克·福爾摩斯 | 300 | 52.50 | 15750 |
| 8700 | 藍(lán)傘 | 200 | 15.00 | 3000 |
| 5086 | 格列佛游記 | 160 | 8.40 | 1344 |
| 1272 | 海倫·凱勒 | 150 | 8.00 | 1200 |
4)師(/) (4) Division (/))
It is utilized to perform division procedures on the information things, things incorporate either a single section or different segments.
它用于對(duì)信息事物執(zhí)行劃分過程,信息包含單個(gè)部分或不同的段。
Implementation:
實(shí)現(xiàn)方式:
SELECT bookno, name, cost, discount, cost/discount AS "Final Cost" FROM BOOKS;Output
輸出量
| 9871 | Nancy Drew | 200 | 12.50 | ?16.00? |
| 9560 | Goosebump | 250 | 30.00 | 8.33 |
| 9810 | Sherlock Holmes | 300 | 52.50 | 5.71 |
| 8700 | The Blue Umbrella | 200 | 15.00 | 13.33 |
| 5086 | Gulliver Travels | 160 | 8.40 | 19.04 |
| 1272 | Hellen Keller | 150 | 8.00 | 18.75 |
| 9871 | 南希·德魯 | 200 | 12.50 | ?16.00? |
| 9560 | 雞皮ump | 250 | 30.00 | 8.33 |
| 9810 | 夏洛克·福爾摩斯 | 300 | 52.50 | 5.71 |
| 8700 | 藍(lán)傘 | 200 | 15.00 | 13.33 |
| 5086 | 格列佛游記 | 160 | 8.40 | 19.04 |
| 1272 | 海倫·凱勒 | 150 | 8.00 | 18.75 |
5)模量(%) (5) Modulus (%))
This operator is used to get the remainder when the division operation is performed with the data.
當(dāng)對(duì)數(shù)據(jù)執(zhí)行除法運(yùn)算時(shí),該運(yùn)算符用于獲取余數(shù)。
Implementation:
實(shí)現(xiàn)方式:
SELECT bookno, name, cost, discount, cost%discount AS "Final Cost" FROM BOOKS;Output
輸出量
| 9871 | Nancy Drew | 200 | 12.50 | ?0? |
| 9560 | Goosebump | 250 | 30.00 | 10 |
| 9810 | Sherlock Holmes | 300 | 52.50 | 37.5 |
| 8700 | The Blue Umbrella | 200 | 15.00 | 5 |
| 5086 | Gulliver Travels | 160 | 8.40 | 0.4 |
| 1272 | Hellen Keller | 150 | 8.00 | 6 |
| 9871 | 南希·德魯 | 200 | 12.50 | ?0? |
| 9560 | 雞皮ump | 250 | 30.00 | 10 |
| 9810 | 夏洛克·福爾摩斯 | 300 | 52.50 | 37.5 |
| 8700 | 藍(lán)傘 | 200 | 15.00 | 5 |
| 5086 | 格列佛游記 | 160 | 8.40 | 0.4 |
| 1272 | 海倫·凱勒 | 150 | 8.00 | 6 |
翻譯自: https://www.includehelp.com/sql/arithmetic-operators.aspx
sql算術(shù)運(yùn)算符
總結(jié)
以上是生活随笔為你收集整理的sql算术运算符_SQL中的算术运算符的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 计算机中央处理器cpu_中央处理器(CP
- 下一篇: 有线电视pcr是什么意思_有线电视的完整