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
Microsoft SQL Server 2008

Avatar of undefined
Last Comment
searchsanjaysharma

8/22/2022 - Mon
Jim Horn

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
Gregory Miller

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
searchsanjaysharma

ASKER
tx
All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck