February 8, 2017 at 12:59 am
Here is the SQL querySELECT ROUND (300 /(CONVERT(decimal(4,2),54)),2) AS [Total]
Below is my result:
Total
5.560000
But I want result like this,
Total
5.56
Thanks in Advance,
Best Regards,
Poornima
February 8, 2017 at 1:31 am
Try
SELECT CONVERT(decimal(4,2),ROUND (300.0 /54,2)) AS [Total]
February 8, 2017 at 1:52 am
Hi,
We should not convert the number from 300 to 300.0 because I have dynamic number coming.
Regards,
Poornima
February 8, 2017 at 3:23 am
You'd need to convert it again on the outside. Like below, but why not handle this in your presentation layer? For example, on Excel a format of 0.00 would only ever show to 2 decimal places, but it stores the remainder.SELECT CONVERT(decimal(4,2),ROUND(300 / (CONVERT(decimal(4,2),54)),2)) AS [Total]
Thom~
Excuse my typos and sometimes awful grammar. My fingers work faster than my brain does.
Larnu.uk
February 8, 2017 at 4:14 am
poornima.s_pdi - Wednesday, February 8, 2017 1:52 AMHi,We should not convert the number from 300 to 300.0 because I have dynamic number coming.
Regards,
Poornima
I was not giving you an exact solution, thought you would get the solution from my reply. As Thom suggested, it is better that you handle it in the application.
February 8, 2017 at 6:43 pm
Thanks Thom and Roshan Joseph.
I tried all other functions to round off.
Atlast I got it.
SELECT cast(ROUND (300 /(CONVERT(decimal(10,5),54)),2) as numeric(36,2))
This query seems to solve my issue.
Both your answers helped me to solve my issue.
Thanks a lot.
Regards,
Poornima
Viewing 6 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply