SELECT SUM(X) AS columnA, CASE WHEN Y = TRUE THEN 'VAR' ELSE 'VAR2' END
Then I group by to get the counts but how do I sum X when Y is TRUE only? Or get the % of A in relation to true/untrue?
how do I sum X when Y is TRUE only?
SELECT SUM(CASE WHEN Y = TRUE THEN X ELSE 0 END)
9 People found this is helpful