protected function convertToCountQuery($sql)
    {
        try {
            $this->checkForMainOffsetOrLimit($sql);
        } catch (\Exception $e) {
            throw $e;
        }

        return "SELECT
                    COUNT(*) as pagination_count
                " . $this->stripQueryToUnnestedKeyword($sql) . "
                LIMIT
                    1";
    }