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 2008 Forums
 Transact-SQL (2008)
 Decimal point

Author  Topic 

Sun Foster
Aged Yak Warrior

515 Posts

Posted - 2011-02-24 : 11:37:59
I like to display one decimal point with the result of division.
For example, 7/12 = 58.3% (a/b=xx.x%)
How to use cast and dec function to make it?

wided
Posting Yak Master

218 Posts

Posted - 2011-02-24 : 11:46:34
declare @var dec(15,2)

select @var = (7/12.0)*100
le résultat est 58.33

wided
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2011-02-24 : 11:52:19
select cast((7/12.0)*100 as decimal(4,1))

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -