What exactly you want to count? Only consumed? Or consumed by goal? If the second option, you need group by statment.
SELECT count(consumed) as count FROM (some select) alias
Or
SELECT count(consumed) as count, goal FROM (some select)
alias Group by goal
solved COUNT and GROUP BY doesn’t works as expected [closed]