Solved

Divide the results of two queries

Posted on 2008-10-29
2
951 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Major Incident Management Communications

Major incidents and IT service outages cost companies millions. Often the solution to minimizing damage is automated communication. Find out more in our Major Incident Management Communications infographic.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

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…
Occasionally there is a need to clean table columns, especially if you have inherited legacy data. There are obviously many ways to accomplish that, including elaborate UPDATE queries with anywhere from one to numerous REPLACE functions (even within…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

739 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