Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
fcoreyesv
Starting Member
18 Posts |
Posted - 2008-07-29 : 12:39:35
|
| Hi all,I need a select statement that returns a value based on a length divided by 12. If the value is between .01 and 12 the result should be 1. If the value is between 12.01 and 24 the it should return 2.In other words it should return the result of the division by 12 but when there is a REMAINDER then the value should go up to the NEXT integer value. So if the value is 36.5 divided by 12 = 3.0416 the result should be 4.I am working SQL 2005.Any suggestions will be greatly appreciated.Jose Reyes |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-07-29 : 12:44:59
|
| SELECT cieling(value/12) |
 |
|
|
fcoreyesv
Starting Member
18 Posts |
Posted - 2008-07-29 : 13:20:18
|
| Thanks it works. I noticed that the value needs to be entered as floating in order to work.If an integer is entered it does not go UP the next integer.Select Ceiling (13.0/2) |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-07-29 : 13:33:04
|
quote: Originally posted by fcoreyesv Thanks it works. I noticed that the value needs to be entered as floating in order to work.If an integer is entered it does not go UP the next integer.Select Ceiling (13.0/2)
yup. if your field is integer use like thisSelect Ceiling (field * 1.0/2) |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2008-07-29 : 13:33:34
|
That's because the result already is integer and there's no decimal to round up. E 12°55'05.25"N 56°04'39.16" |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2008-07-30 : 04:05:14
|
| http://sqlblogcasts.com/blogs/madhivanan/archive/2008/01/16/beware-of-implicit-conversions.aspxMadhivananFailing to plan is Planning to fail |
 |
|
|
|
|
|