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
searchsanjaysharmaAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
Gregory MillerConnect With a Mentor General ManagerCommented:
SELECT CAST(round(AVG(CONVERT(dECIMAL(10,2),IMS)),2) AS DECIMAL, 2)

Open in new window

0
 
Jim HornMicrosoft SQL Server Developer, Architect, and AuthorCommented:
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

0
 
searchsanjaysharmaAuthor Commented:
tx
0
All Courses

From novice to tech pro — start learning today.