var sidebar_align = 'right';
var content_container_margin = parseInt('290px');
var sidebar_width = parseInt('270px');
Unanswered: Tricky SELECT Statement
I'm just hoping that someone might be able to help me out with a tricky SELECT statement that I can't get my head around.
I have two tables - one that contains SERVER items, and another that contains performance ALERTS for those servers.
Here are some relevant fields:
I need to write a SELECT statement that gives me all of the servers for a particular account. e.g.
SELECT serverid, servername FROM servers WHERE accountid=123
and also a COUNT of the number of alerts that each server currently has.
So, the end result might look something like this:
serverid servername numalerts
0 svr01 0
1 svr02 3
2 svr03 1
3 svr04 0
Can anyone help out with that?
this is not tricky at all
your basic left outer join count query
, COUNT(alerts.serverid) AS numalerts
ON alerts.serverid = servers.serverid
WHERE servers.accountid = 123
You're a life-saver. Been struggling with that for hours! Thanks so much for the help.