Reserve a decimal place

xiaoxiao2021-04-01  219

Keep the decimal place is a seven digits, showing three decimal SELECT Convert (Decimal (7, 3), field name) from the name

Round returns a digital expression and rounds it into the specified length or accuracy.

Syntax Round (numeric_expression, length [, function])

Parameter numeric_expression

Accurate digital or approximate digital data type categories express (except Bit data types).

Length

It is numeric_expression will be the accuracy of four rounds. Length must be tinyint, smallint or int. When Length is a positive number, Numeric_Expression is rounded into the number of decigitors specified for Length. When Length is a negative number, Numeric_Expression is rounded from the left side of the decimal point as specified by LENGTH.

FUNCTION

Is the type of operation to be performed. Function must be Tinyint, Smallint or Int. If the value of function or function is omitted is 0 (default), Numeric_Expression will be rounded. When the value other than 0 is specified, the numeric_expression will be truncated.

The return type returns the same type as the numeric_expression.

Note Round always returns a value. If Length is a negative number and greater than the number of numbers before the decimal point, Round will return 0.

Example Results Round (748.58, -4) 0

When Length is negative, regardless of the data type, Round will return a four-round numeric_expression.

Example Results Round (748.58, -1) 750.00 Round (748.58, -2) 700.00 ROUND (748.58, -3) 1000.00

Example A. Use the Round and Estimation Value to display two expressions, indicating that the Round function is used and the last number is always an estimate.

Select Round (123.9994, 3), Round (123.9995, 3) GO

The following is the result set:

------------ ----------- 123.9990 124.0000

B. Use the Round and the surround approximate approximate value to display the rounded and approximation.

Sentence Results Select Round (123.4545, 2) 123.4500 SELECT ROUND (123.45, -2) 100.00

C. Using the ROUND truncation Next case Use two SELECT statements to explain the difference between the four entry and truncation. The first statement is rounded from the results. The second statement truncation result.

Sentence results Select Round (150.75, 0) 151.00 SELECT ROUND (150.75, 0, 1) 150.00

转载请注明原文地址:https://www.9cbs.com/read-131208.html

New Post(0)