Вниз
Скачать: CL | DM;

Округление в SQL   Найти похожие ветки 

 
hooch ©   (2003-03-26 14:17) [0]

Здравствуйте Господа !

нужно позчитать положим такое выражение (10+20/30*4000000000)

DECLARE @Value FLOAT
SET @Value = 10+20/30*4000000000

в данном случае результ = 10, почему понятно, что бы результат был "верный" надо вместо 20 написать 20.0, так вот вопрос, можно ли как - нибудь получить верный результат не изменяя строку (10+20/30*4000000000) ???


 
stone ©   (2003-03-26 14:28) [1]

Что то я не совсем понял вопрос. Если интересует округление до какого-то знака, то:

Syntax
ROUND ( numeric_expression , length [ , function ] )

Arguments
numeric_expression

Is an expression of the exact numeric or approximate numeric data type category, except for the bit data type.

length

Is the precision to which numeric_expression is to be rounded. length must be tinyint, smallint, or int. When length is a positive number, numeric_expression is rounded to the number of decimal places specified by length. When length is a negative number, numeric_expression is rounded on the left side of the decimal point, as specified by length.

function

Is the type of operation to perform. function must be tinyint, smallint, or int. When function is omitted or has a value of 0 (default), numeric_expression is rounded. When a value other than 0 is specified, numeric_expression is truncated.



 
hooch ©   (2003-03-26 14:32) [2]

нет, интересует не округление :-)
при расчет выражения (10+20/30*4000000000) сервер считает что результат должен быть int и возвращает 10, но действительный результат получится если написать
10+CAST(20 AS FLOAT)/30*4000000000
Интересует, как не изменя исходной строки 10+20/30*4000000000, получить "правильное" значение ?



Страницы: 1 вся ветка

Скачать: CL | DM;



Память: 0.45 MB
Время: 0.011 c
14-44423
cd1
2003-03-28 16:22
2003.04.14
FastReport 2.47


3-44041
Roman_kv
2003-03-22 15:23
2003.04.14
CheckBox в DBGrid


1-44179
Timer
2003-04-03 20:43
2003.04.14
Работа с RichEdit


1-44165
Cherepovets
2003-04-01 12:59
2003.04.14
TRegistry процедура или функция


14-44337
sid
2003-03-30 23:40
2003.04.14
А здесь здорово: Написал 2 часа назад 2 вопроса и уже ответили




   Наверх