Jump to content

1.2 to 1.5 and 1.7 to2


kasper

Recommended Posts

hi all ,It is a query that do some calculations.the user wants to truncate the final number as follows:if it is 1.3, 2.4 , 5.25 then it should be truncated to 1.5 , 2.5 , 2.5 and if it is 1.6 , 2.63 , 1.85 it should be truncated to 2 , 3 , 2is this possible using SQL ??

Link to comment
Share on other sites

Hi Kasper,yes, but it it would be complicated. I think you need to convert the number to an integer, subtract the integer from the original number, compare the result of that to 0.5 to decide what value to add to the integer to get your 'rounded to nearest 0.5' value that I think you're aiming for. SQL is really meant for querying databases, but it can produce 'calculated fields', so it could do what you want. It might be simpler with PHP.Plantigrade

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...