Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Sql Syntax Help

Posted on 2008-06-20
2
Medium Priority
?
301 Views
Last Modified: 2010-03-20
Hello, please reffer to my question here:

http://www.experts-exchange.com/Programming/Languages/SQL_Syntax/Q_23494097.html

I chose to use:
select s.serverip, p.serverid, isnull(p.processCnt ,0) processCnt
from servers s left outer join
( Select serverid, count(1) processCnt from processqueue
Group by serverid) as p
on s.serverid = p.serverid And s.status = 100
and p.processCnt <= s.capacity
order by p.processCnt

But, I found an issue with it after I closed the question.  The problem is that p.serverid is returning null when p.processCnt  returns zero.  I need it to return the ServerId and not a null value. How can I fix this?

Thanks Very Much!
0
Comment
Question by:grogo21
[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 2

Assisted Solution

by:jgoeders
jgoeders earned 400 total points
ID: 21835326
Hmmm....it seems that your sub-query p is counting records.  If the count is 0 that means there are no records.  How will it get a serverID out of no records?
0
 

Accepted Solution

by:
grogo21 earned 0 total points
ID: 21835586
Solution:

select s.serverip, s.serverid, count(*) as processes
from servers s left outer join processqueue p on s.serverid = p.serverid
where s.status = 100
group by s.serverid, p.serverid, s.capacity, s.serverip
having count(*) < s.capacity
order by count(*)

Thanks!
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

An alternative to the "For XML" way of pivoting and concatenating result sets into strings, and an easy introduction to "common table expressions" (CTEs). Being someone who is always looking for alternatives to "work your data", I came across this …
One of the most important things in an application is the query performance. This article intends to give you good tips to improve the performance of your queries.
Via a live example, show how to backup a database, simulate a failure backup the tail of the database transaction log and perform the restore.
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.

610 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