QuerySelect Id,Count(Case when Value=0 then 1 else null end) Unconsumed,Count(Case when value > 0 then 1 else null end)Consumed from table1 group by IdHope that this query helps someone.