Sql Syntax Help
Posted on 2008-06-17
Hello how can i select all serverid in servers and get a count of each instance in processqueue. The sql below returns no results if processqueue contains no records. I would like it to return a count of zero if an serverid is not currently in processqueue. I need this to be as efficent as possible as it will execute several times a second.
select top 1 s.serverip, p.serverid
from servers s, processqueue p
where(s.serverid = p.serverid And s.status = 100)
group by s.serverid, p.serverid, s.capacity, s.serverip
having count(*) <= s.capacity
order by count(*)
Thanks Very Much!