public function sql()
    {
        if ($this->active()) {
            if ($this->hasFilters()) {
                $sql = $this->byFilters();
                if ($this->isNegating()) {
                    return $this->operator().' '.$sql;
                }
                return $sql;
            }

            if ($this->hasCondition()) {
                $sql = $this->byCondition();
                if ($this->isNegating()) {
                    return $this->operator().' ('.$sql.')';
                }
                return $sql;
            }

            if ($this->hasFields()) {
                return $this->byPredicate();
            }
        }

        return '';
    }