Hello, please reffer to my question here:
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!