В приложении \ Exceptions \ Handler.php
protected function unauthenticated($request, AuthenticationException $exception)
{
if ($request->expectsJson()) {
return response()->json(['error' => 'Unauthenticated.'], 401);
}
return redirect()->guest(route('auth.login'));
}
Используйте ROW_NUMBER()
и подзапрос:
SELECT TOP 10 c.*
FROM (SELECT COUNT(*) as [# of Complaints],
state_name, company
ROW_NUMBER() OVER (PARTITION BY company ORDER BY COUNT(*) DESC) as seqnum
FROM dbo.Consumer_Complaints
GROUP BY company, state_name
) c
WHERE seqnum = 1
ORDER BY [# of Complaints] DESC;