Главная страница
    Top.Mail.Ru    Яндекс.Метрика
Форум: "Базы";
Текущий архив: 2003.04.14;
Скачать: [xml.tar.bz2];

Вниз

Округление в 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;
Скачать: [xml.tar.bz2];

Наверх





Память: 0.44 MB
Время: 0.011 c
4-44505
Xi2
2003-02-12 20:07
2003.04.14
Как узнать IP на компе


3-44057
Huc
2003-03-24 16:12
2003.04.14
---|Ветка была без названия|---


14-44376
Supreme 2
2003-03-26 23:34
2003.04.14
Знакомства в Интернете


3-44077
iusupp
2003-03-23 11:16
2003.04.14
как правильно делать расчет по полям DBGrid...?


4-44515
Alexander
2003-02-14 16:44
2003.04.14
Есть Handle иконки, как мне её сохранить на диск, желательно с





Afrikaans Albanian Arabic Armenian Azerbaijani Basque Belarusian Bulgarian Catalan Chinese (Simplified) Chinese (Traditional) Croatian Czech Danish Dutch English Estonian Filipino Finnish French
Galician Georgian German Greek Haitian Creole Hebrew Hindi Hungarian Icelandic Indonesian Irish Italian Japanese Korean Latvian Lithuanian Macedonian Malay Maltese Norwegian
Persian Polish Portuguese Romanian Russian Serbian Slovak Slovenian Spanish Swahili Swedish Thai Turkish Ukrainian Urdu Vietnamese Welsh Yiddish Bengali Bosnian
Cebuano Esperanto Gujarati Hausa Hmong Igbo Javanese Kannada Khmer Lao Latin Maori Marathi Mongolian Nepali Punjabi Somali Tamil Telugu Yoruba
Zulu
Английский Французский Немецкий Итальянский Португальский Русский Испанский