Главная страница
Top.Mail.Ru    Яндекс.Метрика
Текущий архив: 2003.04.14;
Скачать: 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 вся ветка

Текущий архив: 2003.04.14;
Скачать: CL | DM;

Наверх




Память: 0.47 MB
Время: 0.019 c
14-44422
DenKop
2003-03-27 07:34
2003.04.14
Кому нужна разовая работа??!!!!!!!


1-44156
9600
2003-04-03 14:59
2003.04.14
TVolumeControl - кто-нибудь о таком слышал ???


4-44502
E_Dimon
2003-02-13 23:43
2003.04.14
Win32 API function failed


7-44484
NetKnight
2002-12-04 16:06
2003.04.14
Program Shortcut ?


14-44451
Таня
2003-03-14 09:33
2003.04.14
Уважаемый Мазут Береговой!