I was wondering if this code would work in a sub query, not sure of the syntax.In this example, I am trying to get a count of two different types of alerts (ODC &ODW) from column Situation Name.. I want to get all the counts in one query so I can eventually do some neat graphs with the data.
Select
Count1=(Select Count (*) From TIVOLI."Status_History"
Where "Situation_Name" Like 'ODC%'),
Count2=(Select Count(*) From TIVOLI."Status_History"
Where "Situation_Name" Like 'ODW%');
Try This:
-
-
SELECT SUM(CASE WHEN situation_name LIKE 'ODW%' THEN 1 ELSE 0 END) cnt_odw, SUM(CASE WHEN situation_name LIKE 'ODC%' THEN 1 ELSE 0 END) cnt_odc FROM TIVOLI."Status_History
-
-