ns_db 0or1row is just a special form of ns_db select, the first returns a set of columns or null, the latter a ns_set of columns through which you can iterate with ns_db getrow.
The first code sample doesn't work because the 'set query' already returns the 'count(*)', not a query that needs to be executed. You could do ns_set get $query "count" (I think it's count, you should really 'select count(*) as cnt from coa')