Very simple use case, when using distinct with pagination on sql server, there are two issues. Row count is incorrect. The sql statement that laravel converted is [select count (*) as aggregate from ...