kasper Posted February 4, 2006 Share Posted February 4, 2006 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 More sharing options...
plantigrade Posted February 5, 2006 Share Posted February 5, 2006 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 More sharing options...
aspnetguy Posted February 6, 2006 Share Posted February 6, 2006 yes it would be far simpler to just reteive the values and then do the calculations on the server side. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now