Click here to Skip to main content
15,907,231 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Dear all,

I want rounded valuel
For Example--
97/10 answer must be 10, but how?
Posted
Comments
hypermellow 3-Jun-14 6:17am    
What do you mean 97/10 answer must be 10?
Nelek 3-Jun-14 6:52am    
97/10 = 9.7 --> Rounded = 10
hypermellow 3-Jun-14 6:56am    
Thanks ... worked it out after read OGs solution.

Try:
SQL
SELECT (97 + (10 - 1)) / 10
 
Share this answer
 
Comments
Nelek 3-Jun-14 6:54am    
101/9 would not be 11 with that logic. Has SQL no round function?
hypermellow 3-Jun-14 6:58am    
Hi Nelek,
OGs solution produces a result of 10.
Paste into a query window and run it.
Nelek 3-Jun-14 7:07am    
I know, but that will only work if the divisor is 10, and I think the OP asked it more general, using just an example of 97/10.
hypermellow 3-Jun-14 7:02am    
MSSQL Round function:
http://technet.microsoft.com/en-us/library/ms175003%28v=sql.110%29.aspx
Another one to try:

SQL
DECLARE @number DECIMAL(10,2)
DECLARE @divisor DECIMAL(10,2)
DECLARE @result DECIMAL(10,0)

SELECT @number=97
SELECT @divisor=10
SELECT @result = (@number/@divisor)

PRINT CONVERT(VARCHAR(32),@result)
 
Share this answer
 
CAST(ROUND( CAST(97 as DECIMAL) /CAST(10 as DECIMAL),0) AS INT)
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900