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 sums...

select  sum(case when z = 1 else 0 end) b,         sum(case when z = 2 else 0 end) c    tablename 

Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -