Sql server 使用sqlsrv数据库时发生Laravel datatable分页错误

Sql server 使用sqlsrv数据库时发生Laravel datatable分页错误,sql-server,laravel,yajra-datatable,Sql Server,Laravel,Yajra Datatable,我在laravel中使用DataTableServerSide显示用户列表,并使用sqlsrv作为数据库。当我第一次加载表时,它会加载数据,但当我单击分页时,它会抛出错误 Exception Message:↵↵SQLSTATE[42000]: [Microsoft][ODBC Driver 17 for SQL Server][SQL Server]The ORDER BY clause is invalid in views, inline functions, derived tables

我在laravel中使用DataTableServerSide显示用户列表,并使用sqlsrv作为数据库。当我第一次加载表时,它会加载数据,但当我单击分页时,它会抛出错误

Exception Message:↵↵SQLSTATE[42000]: [Microsoft][ODBC Driver 17 for SQL Server][SQL Server]The ORDER BY clause is invalid in views, inline functions, derived tables, subqueries, and common table expressions, unless TOP, OFFSET or FOR XML is also specified. 
(SQL: select count(*) as aggregate from (select * from (select [Name], [PhoneNumber], [Email],(SELECT id FROM configurations bmd WHERE bmd.id=userprofiles.UserId AND bmd.Name IN('test1', 'test2','test3')) as is_connected, row_number() over (order by (select 0)) as row_num from [userprofiles] where cast(created_at as date) BETWEEN '2020-11-01' AND '2020-11-24') as temp_table where row_num between 11 and 20 order by row_num) count_row_table)
这是我正在使用的laravel代码

$users = $this->findModel()->select(['Name', 'PhoneNumber', 'Email'])->addSelect(\DB::raw("(SELECT id FROM configurations bmd WHERE bmd.UserProfileId=userprofiles.UserId AND bmd.Name IN('C3i', 'c5i','F6i')) as is_connected"))->whereRaw("cast(created_at as date) BETWEEN '$start_date' AND '$end_date'")->limit($length)->offset($start);  $users = $this->findModel()->select(['Name', 'PhoneNumber', 'Email'])->addSelect(\DB::raw("(SELECT id FROM configurations bmd WHERE bmd.UserProfileId=userprofiles.UserId AND bmd.Name IN('C3i', 'c5i','F6i')) as is_connected"))->whereRaw("cast(created_at as date) BETWEEN '$start_date' AND '$end_date'")->limit($length)->offset($start);



$total = $this->findModel();

        $filter_total = $total->whereRaw("cast(created_at as date) BETWEEN '$start_date' AND '$end_date'");
        if ($search != '') {
            $filter_total = $filter_total->whereRaw(" (Name like '%$search%' OR Email like '%$search%' OR PhoneNumber like '%$search%')");
        }

        $filter_total = $filter_total->count();
        $total = $total->count();
            ->skipPaging()
            ->with([
                "recordsTotal" => $total,
                "recordsFiltered" => $filter_total,
            ])
            ->make(true);
请让我知道我做错了什么