Counting on one field is all I ever needed, however, i need 3 this go around...
1 table, 400,000+ records, need to return distinct computers (GROUP BY <assuming) with a count on severity of 'Category I','Category II',Category III'
I currently have:
SELECT HOST,
(select count(severity) from table where severity = 'Category I') AS [Cat I],
(select count(severity) from table where severity = 'Category II') AS [Cat II],
(select count(severity) from table where severity = 'Category III') AS [Cat III]
FROM table
GROUP BY HOST
but returns:
HOST Cat I Cat II Cat III
comp1 73622 260071 270901
comp2 73622 260071 270901
comp3 73622 260071 270901
* host field is correct, however counts are not by host but database overall...
should return something like:
HOST Cat I Cat II Cat III
comp1 3 12 20
comp2 1 4 12
comp3 6 19 10
....
Thanks
1 table, 400,000+ records, need to return distinct computers (GROUP BY <assuming) with a count on severity of 'Category I','Category II',Category III'
I currently have:
SELECT HOST,
(select count(severity) from table where severity = 'Category I') AS [Cat I],
(select count(severity) from table where severity = 'Category II') AS [Cat II],
(select count(severity) from table where severity = 'Category III') AS [Cat III]
FROM table
GROUP BY HOST
but returns:
HOST Cat I Cat II Cat III
comp1 73622 260071 270901
comp2 73622 260071 270901
comp3 73622 260071 270901
* host field is correct, however counts are not by host but database overall...
should return something like:
HOST Cat I Cat II Cat III
comp1 3 12 20
comp2 1 4 12
comp3 6 19 10
....
Thanks