rounding

1. Member
Join Date
Dec 1969
Posts
94

## rounding

Hi everyone<BR>This is my query<BR>DECLARE @MAX AS DECIMAL(2)<BR>DECLARE @MIN AS DECIMAL(2)<BR>DECLARE @RANGE AS DECIMAL(2)<BR>SET @MAX = 80<BR>SET @MIN = 30<BR>set @range = (@max - @min)/6 <BR>select @range<BR>select @max<BR>select @min<BR>when I execute it, I expect the @range value to have 2 decimal places. How do i get to display those decimal places<BR><BR>for eg. my query should have the @range value = 8.33<BR><BR>Thanks

2. Senior Member
Join Date
Dec 1969
Posts
11,247

## FRom the BOL

decimal[(p[, s])] and numeric[(p[, s])] <BR>Fixed precision and scale numbers. When maximum precision is used, valid values are from - 10^38 -1 through 10^38 - 1. The SQL-92 synonyms for decimal are dec and dec(p, s). <BR>p (precision) <BR>Specifies the maximum total number of decimal digits that can be stored, both to the left and to the right of the decimal point. The precision must be a value from 1 through the maximum precision. The maximum precision is 28 unless the server is started with the /p parameter of sqlservr. If the /p parameter is specified, the maximum precision is 38; therefore, 0 &#060; p &#060;=38. <BR>s (scale) <BR>Specifies the maximum number of decimal digits that can be stored to the right of the decimal point. Scale must be a value from 0 through p. The default scale is 0; therefore, 0 &#060;= s &#060;= p. Maximum storage sizes vary, based on the precision.

3. Member
Join Date
Dec 1969
Posts
94

## EOM, Thanks

Thanks, I Got it

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•