Skip to main content

List some Aggregates methods provided by query builder in Laravel?

Published 1 min readMarkdown
Part of seriesLaravel
List some Aggregates methods provided by query builder in Laravel?
  • count

  • max

  • min

  • avg

  • sum

use Illuminate\Support\Facades\DB;

$users = DB::table('users')->count();

$price = DB::table('orders')->max('price');

$price = DB::table('orders')
                ->where('finalized', 1)
                ->avg('price');

About the author

  • Full Stack Developer with a passion for building web applications. PHP, Node.js, Laravel, MySQL, MongoDB. Love collaborating & making a difference

No comments yet. Be the first to comment.

More from this blog