Link to home
Create AccountLog in
Avatar of searchsanjaysharma
searchsanjaysharma

asked on

How to round off in sql server

SELECT round(AVG(CONVERT(dECIMAL(10,2),IMS)),2) fROM IND13I.DBO.MSTMASSSTUDENTS
WHERE Course='B.Arch' and semester=1 and subjectcode='ar-101'
and ims not in('i','e','l','','ab')

The result is 30.800000

Why not 30.80
Avatar of Jim Horn
Jim Horn
Flag of United States of America image

Not sure why, but ROUND does the rounding, but does not alter the percision/scale of the value being rounded.  

CAST(your_number as decimal(19,2)) will return only two decimal places.
SELECT ROUND(18.2000000,2)
SELECT CAST(18.200000 as decimal(19,2))

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Gregory Miller
Gregory Miller
Flag of United States of America image

Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
Avatar of searchsanjaysharma
searchsanjaysharma

ASKER

tx