Solved

Divide the results of two queries

Posted on 2008-10-29
2
918 Views
Last Modified: 2012-08-13
I'm not sure what I'm doing wrong here.. I have these two queries and both return positive values in the 1k+ range on their own.  The first returns a value of 1277  and the second returns a value of 6559.  However, when I try to divide them to return a percentage I get 0, if I do the math on a calculator I get
0.194, which is the value I actually want.  I'm sure it's something simple so thanks in advance.  

SELECT Unassigned/Total FROM
(SELECT COUNT(IPAddress) Unassigned FROM Assets INNER JOIN
Contacts ON Assets.BusID = Contacts.BusID WHERE Business_Contact = 'NOT_ASSIGNED') AS TEMP1,
(SELECT COUNT(IPaddress) Total FROM Assets) AS TEMP2;
0
Comment
Question by:jclemo
2 Comments
 
LVL 14

Accepted Solution

by:
Binuth earned 250 total points
ID: 22838555
use cast...
SELECT CAST(Unassigned AS DECIMAL)/CAST(Total AS DECIMAL) FROM

(SELECT COUNT(IPAddress) Unassigned FROM Assets INNER JOIN

Contacts ON Assets.BusID = Contacts.BusID WHERE Business_Contact = 'NOT_ASSIGNED') AS TEMP1,

(SELECT COUNT(IPaddress) Total FROM Assets) AS TEMP2;

Open in new window

0
 

Author Closing Comment

by:jclemo
ID: 31511557
heh.. I knew it was simple.. thanks for the help Binuth.
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

'Between' is such a common word we rarely think about it but in SQL it has a very specific definition we should be aware of. While most database vendors will have their own unique phrases to describe it (see references at end) the concept in common …
If you have heard of RFC822 date formats, they can be quite a challenge in SQL Server. RFC822 is an Internet standard format for email message headers, including all dates within those headers. The RFC822 protocols are available in detail at:   ht…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now