[英]How do I get distinct values from the table along with the count of how many rows there are containing that value
IN SQL(如果可能的话如何在 Laravel Eloquent 中编写),如果有 10 行 MySQL 的值为 IN',4 行的值为 'US',7 行的值为 'FR'; 我希望查询结果为三行:
SELECT column_name, count(*) as c FROM table_name GROUP BY column_name ORDER BY c DESC
Model::query()->groupBy('country_name')->select('counrty_name',DB::raw('COUNT(1)'))->get()
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.