Support the ongoing development of Laravel.io →
posted 10 years ago
Database
Last updated 2 years ago.
0
Model::selectRaw('count(*), min(some_field) as someMin, max(another_field) as someMax')->first();
// or in this case maybe better query builder instead of Eloquent:
DB::table('someTable')->selectRaw('count(*), min(some_field) as someMin, max(another_field) as someMax')->first();
Last updated 2 years ago.
0

Thanks. I knew about selectRaw but was wondering if there was some way a little more structured. It would be nice if the aggregate functions would return a Builder object so you could chain them together.

Last updated 2 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

russdirks russdirks Joined 16 Jun 2014

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.