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 |
|
mike123
Master Smack Fu Yak Hacker
1462 Posts |
Posted - 2009-03-05 : 03:19:49
|
| Hi,I have a statement in which I am trying to round UP. If there is any remainder I want to round up, not sure if there is a function in SQL for this ? I tried CEILING but its not exactly what I need. (21 / 20) = 2(41 / 20) = 3(49 / 20) = 3(20 /20) = 1 any help much appreciated!Thanks again!mike123 |
|
|
ddramireddy
Yak Posting Veteran
81 Posts |
Posted - 2009-03-05 : 03:23:01
|
| just add 19 to that number and divide with 20, its enough.select (@Number + 19) / 20 |
 |
|
|
asgast
Posting Yak Master
149 Posts |
Posted - 2009-03-05 : 04:01:10
|
| SELECT @a/@b + CASE WHEN @a % @b > 0 THEN 1 ELSE 0 end; |
 |
|
|
ayamas
Aged Yak Warrior
552 Posts |
Posted - 2009-03-05 : 05:45:39
|
| select (21 * 1.0 / 20)select (41 * 1.0 / 20) |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
|
|
Jai Krishna
Constraint Violating Yak Guru
333 Posts |
Posted - 2009-03-05 : 07:01:07
|
| cieling works once check the results of below statementsselect ceiling(21*1.0/20)select ceiling(41*1.0/20)select ceiling(49*1.0/20)select ceiling(20*1.0/20)Jai Krishna |
 |
|
|
|
|
|