jondcampbell
10/9/2015 - 11:08 PM

query a prices table, finding me the companies with the most products. uses laravel and db query builder. grouping and ordering

query a prices table, finding me the companies with the most products. uses laravel and db query builder. grouping and ordering

			$companies = DB::table('prices')
				->select(DB::raw('company_id, COUNT(*) as total_products'))
				->groupBy('company_id')
				->orderBy('total_products', 'desc')
				->get();