I have a SQL that returns a cnt1 and cnt2 for each Event_ID, while testing a condition for column “POSA”
this returns the following as desired:
Event_ID | CNT1 | CNT2
I would like to add another condition to each CASE statement that tests if another column “S” in the same table is distinct. Below is the code snippet:
SELECT Event_ID,
sum
(CASE WHEN POSA IN ('SX', 'DX') THEN 1
ELSE 0
END)
AS cnt1,
sum
(CASE
WHEN POSA IN ('SP', 'DP') THEN 1
ELSE 0
END) AS cnt2
FROM Station_Processed_Info GROUP BY EVENT_ID;
1 Answer