sql integer devision

Solutions on MaxInterview for sql integer devision by the best coders in the world

showing results for - "sql integer devision"
Raymond
25 Jun 2020
1-- When performing division operations on integer values, 
2-- the results will always be integers and the results 
3-- may not always be what you expect.
4
5SELECT 1 / 2; --> Result: 0
6SELECT 1.0 / 2; --> Result: 0.5
7SELECT CAST(1 AS REAL) / 2; --> Result: 0.5
8SELECT 17 / 5; --> Result: 3
9SELECT 17 % 5; --> Result: 2
10
11-- Remember, these are integers and so the result will 
12-- be an integer and 1.0 is not an integer.