|
|
|
#1 |
|
Messages: n/a
Hébergeur: |
When I
SELECT CAST(96.58 AS DECIMAL(10 , 0)), it returns 97. When I SELECT CAST(575629 / 54 AS DECIMAL(10 , 0)), why it returns 10659? It should return 10660, right? What am I missing? Thanks, Faye Larson |
|
|
|
#2 |
|
Messages: n/a
Hébergeur: |
Running this will explain it:
SELECT 575629 / 54 When integer dividend is divided by an integer divisor the result is an integer that has any fractional part of the result truncated, so you get 10659. But try this: SELECT CAST(575629 / 54.0 AS DECIMAL(10 , 0)) or SELECT CAST(1.0 * 575629 / 54 AS DECIMAL(10 , 0)) Those will give you the expected result 10660, because the higher precedence argument data type is the resulting data type of the division. HTH, Plamen Ratchev http://www.SQLStudio.com |
|
![]() |
| Outils de la discussion | |
|
|