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
 General SQL Server Forums
 New to SQL Server Programming
 Number Format Help

Author  Topic 

mgarret
Starting Member

14 Posts

Posted - 2011-09-11 : 22:38:28
Hi All-

Any help is greatly appreciated. All i am trying to do is change the format of a number generated by a function. i am multiplying count(*) by .35 and instead of getting a number like this 36.777777777 I want to get a rounded whole number so like this 37.

select distinct count(*) as Initial_Cohort "Cohort", count(*) * .35 as FY12Target <----- right here is where i need the format
from CHILDTABLE;

flamblaster
Constraint Violating Yak Guru

384 Posts

Posted - 2011-09-12 : 00:03:47
Hi M,

Try:
select distinct count(*) as Initial_Cohort "Cohort", ROUND(count(*) * .35,0)
from CHILDTABLE;
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2011-09-12 : 00:52:48
do you want to always get next whole number or just round it? if former, the earlier suggestion would work. if latter, you need to use CIELING() function instead

see

SELECT ROUND(36.3333333333 ,0),CEILING(36.3333333 )

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -