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 |
Rheinhardt
Yak Posting Veteran
66 Posts |
Posted - 2009-10-08 : 07:03:43
|
Hi,I would like to make two columns one where the figures are rounded up that has >0.4 and one that has figures rounded <0.5?Please assist. |
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2009-10-08 : 07:07:32
|
What about 0.45? N 56°04'39.26"E 12°55'05.63" |
|
|
Rheinhardt
Yak Posting Veteran
66 Posts |
Posted - 2009-10-08 : 07:10:08
|
:)Ok so if you understand what the idea is what would you recommend.I want to have 2 columns to show the effects of the rounding? |
|
|
jimf
Master Smack Fu Yak Hacker
2875 Posts |
Posted - 2009-10-08 : 08:12:15
|
SELECT Col1,[RoundedUp] = CASE WHEN col >= .5 CEILING(Col1) ELSE 0 END ,[RoundedDown] = CASE WHEN col < .5 FLOOR(Col1) ELSE 0 ENDFROM yourTableYou can put whatever you want for the ELSE part (col1, null, etc.)JimEveryday I learn something that somebody else already knew |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2009-10-08 : 08:28:38
|
select col,floor(col+0.5),floor(col) FROM (select '0.45' as col union all select '0.3') yourTableMadhivananFailing to plan is Planning to fail |
|
|
|
|
|