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.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 rounding

Author  Topic 

CSK
Constraint Violating Yak Guru

489 Posts

Posted - 2006-10-03 : 04:21:38
Dear All,
i Just want to round of near by zero
like

if it is 0.3 then 0.5
if it is 0.8 then 1.0
if it's 0.2 then 0

How can i do this

please help me
Regards
Krishnakuamr.C

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2006-10-03 : 04:54:55
[code]round(val / 5, 1) * 5[/code]


KH

Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2006-10-03 : 05:00:41
-- testing script
declare @table table
(
val decimal(10,2)
)
-- create data
insert into @table
select NUMBER * 0.1
from F_TABLE_NUMBER_RANGE(1,20)

select *, convert(decimal(10,2), round(val / 5, 1) * 5)
from @table



KH

Go to Top of Page

ditch
Master Smack Fu Yak Hacker

1466 Posts

Posted - 2006-10-03 : 05:10:20
Very Nice!!!!


Duane.
Go to Top of Page

CSK
Constraint Violating Yak Guru

489 Posts

Posted - 2006-10-03 : 06:26:05
Thank u very much khtan

It's working

Go to Top of Page

harshal_in
Aged Yak Warrior

633 Posts

Posted - 2006-11-10 : 05:28:07
quote:
Originally posted by khtan

round(val / 5, 1) * 5



KH






Thanks khtan!! I was looking for exactly the same thing.

-Harshal.
Go to Top of Page
   

- Advertisement -