James  Tomatov James Tomatov - 4 years ago 144
jQuery Question

Select max values from query - LARAVEL

I have a table with fields:
|| id || name || c_number ||
I have a query:

$query ->select('c_number', DB::raw('count(*) as total'))



I need select from output only value(-s) of
where total is max.
Can you tell me, please, how to do that with query?

Answer Source

You could using a mixture or orderBy() and first().

->select('c_number', DB::raw('count(*) as total'))
->orderBy('total', 'desc')

Hope this helps!

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download