Use `if (empty($this->groupBy) && !$this->distinct)`.