Add Count() support

Refactor to support scalar-type queries, starting with Count