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
 SQL Server Development (2000)
 Round the numbers

Author  Topic 

MattieBala69
Starting Member

30 Posts

Posted - 2005-02-23 : 16:56:23
Hey,
I have a question. I would like to know if i could round this for eg.
2.31 i need this to round to 3
If someone could help me out it would be great. I am on a deadline.
Thank you

rockmoose
SQL Natt Alfen

3279 Posts

Posted - 2005-02-23 : 16:59:58
select ceiling(2.31)

rockmoose
Go to Top of Page

MattieBala69
Starting Member

30 Posts

Posted - 2005-02-23 : 17:07:39
Thank you soooooooo much .
Go to Top of Page

MattieBala69
Starting Member

30 Posts

Posted - 2005-02-24 : 13:56:34
Hey ,
I just found out they dont want the calculation to be like that
for eg between 2.1 and 2.4 i need this to be rounded to 2.

And the other thing is let me first explanin what i have to do for this stor proc
lets say tableA has 3 rows i need to find out what is 10% of that 3 eg 3*.1 = .3 (this should show 0)
eg2. table B has 39 rows -- 39*.1 = 3.9 this should show 4

so now accourding to this result i need to select that particular row set
right now i was doing
Select n Percentage * from table
for the eg i gave u the SQL would pick 1 row for table A
and 4 for table B

NOW I NEED TO DO A SELECT WHERE I WOULD GET 0 ROWS FOR TABLE A
AND 4 FOR TABLE B

PLEASE IF SOMEONE COULD HELP ME OUT IT WOULD BE GREAT.

thank you,
Mattie



Go to Top of Page

rockmoose
SQL Natt Alfen

3279 Posts

Posted - 2005-02-24 : 14:26:44
Something like this ?
declare @rows int
select @rows = round(0.1*count(*),0) from sysobjects

set rowcount @rows
select * from sysobjects where @rows > 0 -- if rowcount is 0, that means all rows

set rowcount 0 -- reset


Edit: replace sysobjects for your table, it was just an axample

rockmoose
Go to Top of Page

MattieBala69
Starting Member

30 Posts

Posted - 2005-02-24 : 14:55:16
thank u soo much
Go to Top of Page
   

- Advertisement -