About count and or null
An example - http://sqlfiddle.com/#!9/9eecb7d/59602

The explanation - COUNT(&lt;expr&gt;) counts all non-NULL values. Comparison operators return boolean values 1(=true) or 0(=false) and both are non-NULL so both would be counted by COUNT(). When you add the or NULL part, the entire expression is still 1 for true but becomes NULL when the comparison returns false (because of the ternary logic definition used in SQL). So the COUNT() only count "trues".

Thats for standard SQL. In MySQL you can use a different trick. Because true and false are actually 1 and 0, you can just sum(t.Status = 'completed') to get the right number without using NULLs.