Solved

How to round off in sql server

Posted on 2013-12-28
3
296 Views
Last Modified: 2014-01-20
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
0
Comment
Question by:searchsanjaysharma
3 Comments
 
LVL 65

Expert Comment

by:Jim Horn
ID: 39743748
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
 
LVL 11

Accepted Solution

by:
Technodweeb earned 500 total points
ID: 39743758
SELECT CAST(round(AVG(CONVERT(dECIMAL(10,2),IMS)),2) AS DECIMAL, 2)

Open in new window

0
 

Author Closing Comment

by:searchsanjaysharma
ID: 39793814
tx
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

This is basically a blog post I wrote recently. I've found that SARGability is poorly understood, and since many people don't read blogs, I figured I'd post it here as an article. SARGable is an adjective in SQL that means that an item can be fou…
SQL Server engine let you use a Windows account or a SQL Server account to connect to a SQL Server instance. This can be configured immediatly during the SQL Server installation or after in the Server Authentication section in the Server properties …
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now