Laravel 8 tutorial in Hindi - Aggregate methods | sum,avg,min,max etc
HTML-код
- Опубликовано: 18 сен 2020
- In this laravel 8 and 9 video tutorial, we learn what is Aggregate function and how to use them with database a simple way. This video is made by anil Sidhu in the Hindi language.
steps of video
aggregate methods in Laravel
what is aggregate methods
Make controller
Use max, avg, min, count, sum
Interview Question for aggregate in laravel
Laravel 9 tutorial in hindi
Laravel 9 playlist in Hindi
• Laravel 9 tutorial in ...
please support me by subscribe, like and comment :) thank you
first method =
$max = DB::table('orders')->max('price');
$min = DB::table('orders')->min('price');
$res=['max_price'=>$max,'min_price'=>$min];
return $res;
second method =
return table('orders')->select(DB::raw("max(price) as max_price,min(price) as min_price"))->get();
Yes you can do this as follows -
function operations(){
$sum = DB::table('storeusers')->sum('id');
$min = DB::table('storeusers')->min('id');
$max = DB::table('storeusers')->max('id');
$avg = DB::table('storeusers')->avg('id');
echo 'SUM ='.$sum.'';
echo 'MIN ='.$min.'';
echo 'MAX ='.$max.'';
echo 'AVG ='.$avg.'';
}
Yes, We can. like this DB::table('table_name')->select(DB::raw("min('price') as min_price, max('price') as max_price"))->get();
Thanks
Please update your query :
DB::table('table_name')->select(DB::raw("min(price) as min_price, max(price) as max_price"))->get();
Thanks
DB::table('members')->select(DB::raw("min(id) as min_price, max(id) as max_price"))->get();
Interview question answer:
DB::table('city')->select(DB::raw('MIN(id) as minid,MAX(id) as maxid'))->get();
Or operator k use KR k bi min or max values use kr skty hn. 2no ek sth
yes
$price = DB::table('orders')->max('price')->min('price');
sayd aise lga skte he condition ??????
How to make hr employees salary.
interview ans:
$min= DB::table('members')->min('id');
$max= DB::table('members')->max('id');
echo 'MIN ='.$min.'';
echo 'MAX ='.$max.'';
$data = DB::table('members')
->select(DB::raw('MIN(id) AS FirstID, MAX(id) AS LastID'))
->get();
what a sweet answer