Created
October 9, 2015 23:08
-
-
Save jondcampbell/88c572072f621d3f5ee3 to your computer and use it in GitHub Desktop.
query a prices table, finding me the companies with the most products. uses laravel and db query builder. grouping and ordering
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$companies = DB::table('prices') | |
->select(DB::raw('company_id, COUNT(*) as total_products')) | |
->groupBy('company_id') | |
->orderBy('total_products', 'desc') | |
->get(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment