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 |
|
joldham
Wiseass Yak Posting Master
300 Posts |
Posted - 2003-01-10 : 14:03:06
|
| Has anyone ever tried to design a Round Up Function? I am trying to create a graph and I need to take the largest member in the dataset and round it up. Any advice?Jeremy |
|
|
jsmith8858
Dr. Cross Join
7423 Posts |
Posted - 2003-01-10 : 14:19:12
|
| Maybe something like:select convert(int, @val + .5)That will round up if @val is .5 or higher. If you ALWAYS want to round up, add .9999999 or something to it.- Jeff |
 |
|
|
royv
Constraint Violating Yak Guru
455 Posts |
Posted - 2003-01-10 : 14:19:22
|
| If I understand correctly, the CEILING function might be what you are looking for.***************************************Death must absolutely come to enemies of the code! |
 |
|
|
joldham
Wiseass Yak Posting Master
300 Posts |
Posted - 2003-01-10 : 14:29:01
|
| CEILING will not work the way I need it to. Let me explain a little further. When you have the following table:October 50November 100December 123I want to take 123 (max value) and round up to 200. I have the following: Round(colValue, Len(colValue)-1). In this case it will round to 100 instead of 200.Jeremy |
 |
|
|
jsmith8858
Dr. Cross Join
7423 Posts |
Posted - 2003-01-10 : 15:37:46
|
| Try adding 99 to it before you round.- Jeff |
 |
|
|
SamC
White Water Yakist
3467 Posts |
Posted - 2003-01-10 : 15:48:54
|
| Sounds like you want round to the number of digits?LEN doesn't tell how many digits are in an integer, just a string/varchar.I haven't tried this, so it'll need debugging but...set colValue = ROUND(colvalue, 1-len(cast(colValue as varchar)))the length value is negative number of digits plus 1.Maybe there's a better way?Sam |
 |
|
|
|
|
|