May 7, 2009 at 12:08 am
I know this could be fairly straightforward but i am sort of stuck on it.
I am writing a query to find the nearest multiple of 12.
I tried to use the below code:
select round ((x+11)/12,0)*12
select CEILING (x/12)*12
but they dont give the desired result.
My aim is
x result
13 12 to be returned
23 24 to be returned
15 12 to be returned
Can some one help?
May 7, 2009 at 4:04 am
Assuming x is an int
select ((x+6)/12)*12
____________________________________________________
Deja View - The strange feeling that somewhere, sometime you've optimised this query before
How to get the best help on a forum
http://www.sqlservercentral.com/articles/Best+Practices/61537Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply