📜  SQL Integer devision - SQL 代码示例

📅  最后修改于: 2022-03-11 15:05:19.980000             🧑  作者: Mango

代码示例1
-- When performing division operations on integer values, 
-- the results will always be integers and the results 
-- may not always be what you expect.

SELECT 1 / 2; --> Result: 0
SELECT 1.0 / 2; --> Result: 0.5
SELECT CAST(1 AS REAL) / 2; --> Result: 0.5
SELECT 17 / 5; --> Result: 3
SELECT 17 % 5; --> Result: 2

-- Remember, these are integers and so the result will 
-- be an integer and 1.0 is not an integer.