sql - Summing 1 Column As Two Separate Values Depending on Another Value in the Row -
i have table has column a, , column z.
i'm doing select on table, summing a.
i want sum(a) "b" if column z = 1, , sum(a) "c" if column z = 2. how can go doing that?
case statement sum
s...
select sum(case when z = 1 else 0 end) b, sum(case when z = 2 else 0 end) c tablename
Comments
Post a Comment