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 ...

Комментарии • 16

  • @codestepbystep
    @codestepbystep  2 года назад +5

    please support me by subscribe, like and comment :) thank you

  • @dummyaccount6317
    @dummyaccount6317 2 года назад +4

    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();

  • @muskangarg1930
    @muskangarg1930 Год назад +1

    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.'';
    }

  • @NareshKumar-xf6rl
    @NareshKumar-xf6rl 3 года назад +15

    Yes, We can. like this DB::table('table_name')->select(DB::raw("min('price') as min_price, max('price') as max_price"))->get();

    • @anilchudasama7698
      @anilchudasama7698 3 года назад

      Thanks

    • @aneeraj81
      @aneeraj81 3 года назад +3

      Please update your query :
      DB::table('table_name')->select(DB::raw("min(price) as min_price, max(price) as max_price"))->get();
      Thanks

  • @aneeraj81
    @aneeraj81 3 года назад +4

    DB::table('members')->select(DB::raw("min(id) as min_price, max(id) as max_price"))->get();

  • @smitshah3905
    @smitshah3905 Год назад +1

    Interview question answer:
    DB::table('city')->select(DB::raw('MIN(id) as minid,MAX(id) as maxid'))->get();

  • @najamhassan6645
    @najamhassan6645 3 года назад

    Or operator k use KR k bi min or max values use kr skty hn. 2no ek sth

  • @mevadakalpesh3529
    @mevadakalpesh3529 3 года назад

    yes

  • @kaziovesh9798
    @kaziovesh9798 3 года назад

    $price = DB::table('orders')->max('price')->min('price');
    sayd aise lga skte he condition ??????

  • @gurucharans9629
    @gurucharans9629 Год назад

    How to make hr employees salary.

  • @sitararafaqat
    @sitararafaqat Год назад

    interview ans:
    $min= DB::table('members')->min('id');
    $max= DB::table('members')->max('id');
    echo 'MIN ='.$min.'';
    echo 'MAX ='.$max.'';

  • @aindreeghosh906
    @aindreeghosh906 Год назад +1

    $data = DB::table('members')
    ->select(DB::raw('MIN(id) AS FirstID, MAX(id) AS LastID'))
    ->get();