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)
 Calculation rounding to 0 in SQL Query

Author  Topic 

jrockfl
Posting Yak Master

223 Posts

Posted - 2005-04-12 : 14:34:55
The broswer percent is coming out as 0 for all the records. a.browsertotal and a.total are all more then 0,
so it rounds it down or something?

SELECT a.total, b.browsertotal, b.browsers, (b.browsertotal / a.total) * 100 AS browserpercent
FROM
(SELECT Count(id) As total
FROM tblbrowsers) a,
(SELECT count(id) as browsertotal, browsers
FROM tblbrowsers
GROUP BY browsers)

X002548
Not Just a Number

15586 Posts

Posted - 2005-04-12 : 14:36:46
SELECT a.total, b.browsertotal, b.browsers, (b.browsertotal / a.total*1.00) * 100 AS browserpercent

Brett

8-)
Go to Top of Page

jrockfl
Posting Yak Master

223 Posts

Posted - 2005-04-12 : 14:40:47
Still comes out as 0, if i multiple instead of divide, then its not zero, but I have to divide in order to create the percent
Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 2005-04-12 : 14:59:42
DECLARE @x int, @y int
SELECT @x = 1, @y = 2
SELECT @x*1.00/@y




Brett

8-)
Go to Top of Page

jrockfl
Posting Yak Master

223 Posts

Posted - 2005-04-12 : 15:05:09
That's way beyond me :)
Will I be able to do that in EM or do I need to use QA?
Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 2005-04-12 : 15:30:02
QA.....where are you doing development then? In EM?

You should do all of your developement in Query Analyzer, saving each sproc as a .sql file.



Brett

8-)
Go to Top of Page

jrockfl
Posting Yak Master

223 Posts

Posted - 2005-04-12 : 15:41:04
Yes, I usually use EM except if I am writting a sp.
Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 2005-04-12 : 15:44:52
Well...open up QA and BOL and leave them open......

Down with GUI's



Brett

8-)
Go to Top of Page
   

- Advertisement -