Monday, May 6, 2013

[SQL Server] Rounding Up with given precision

[SQL Server] Rounding Up with given precision


Rounding Up with given precision

Posted: 05 May 2013 08:20 PM PDT

I would like to round up some figures with given precision. So far I can't find a way to do it. ROUND function doesn't work for me because it can't round up, CEILING doesn't work as well because the results is integer.What I would like to achieve is a rounding up with give precision of 2 places after dot i.e.5.0000016 should be 5.016.1000138 should be 6.117.1200073 should be 7.13Is it any way to do it in SQL?

Use MAX in insert query

Posted: 05 May 2013 06:53 PM PDT

Hi, is it possible to use MAX function in an insert query?I try to write a query similar to this:[code="sql"]INSERT INTO TableName (ID,Value)VALUES (SELECT coalesce(MAX(ID),0) + 1 FROM TableName, 'something')[/code]I get error, Incorrect syntax near the keyword 'SELECT'.Thank you for help.

No comments:

Post a Comment

Search This Blog