Read Catalogue
Rounding in SQL usually has two ways: round and cast (... as decimal ()).
The personal advice is to use the cast method:
Back to Top
Way toround
After testing, the same can be rounded, but round the following example 1 will be an error,
Example 1:select round (0.996123,2) Error: arithmetic overflow errors when converting expression to data type numeric.
Example 2:select round (0.99432,2) results are 0.99000
Back to Top
mode of thecast
Cast Rounding:
SELECT cast (' 123.456 ' as Decimal (2)) ===>123.46select CAST (0.996123 as Decimal (38,2)) results 1.00SELECT CAST (' 123.456 ' as Dec (2)) ===>123.46
If you think reading this blog gives you something to gain, you might want to click " recommend " in the lower right corner.
If you want to find my new blog more easily, click on " Follow me "
If you want to give me more encouragement, you may wish to click on the right, " enjoy your stay"
Blog is his own summary of the results of learning, learning to summarize the knowledge-"analysis of the problem-" to solve the problem.
Where the views/descriptions in the text are incorrect, please correct them.
Thank you for your reading, if you are interested in the content of my blog, please continue to follow my following blog, I am yxtic.
Rounding of SQL Server values