fixed bug where query field was not allowed to be nonexistent in distinct command