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 2005 Forums
 Transact-SQL (2005)
 % query

Author  Topic 

dnf999
Constraint Violating Yak Guru

253 Posts

Posted - 2007-06-01 : 07:01:14
Hi I need a query to display a percentage of a total.

i.e.

select cast(100/150 as decimal(18,2))

should Display: 0.66
but diplays 0.00

Any idea how i change my code to display this?

Thanks

David

bpgupta
Yak Posting Veteran

75 Posts

Posted - 2007-06-01 : 07:36:34
Try this
select cast(100.00/150.00 as decimal(18,2))
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2007-06-01 : 08:23:00
or

select cast(1.0*100/150 as decimal(18,2))


Madhivanan

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

- Advertisement -