Error Query saat menggunakan Case When

 $tbl = DB::table('leave_form')
             ->select('leave_form.status',
             DB::raw('(CASE WHEN leave_form.status = Approved THEN 2 WHEN leave_form.status = Rejected THEN 1 ELSE 4) as orderingstatus'))
              ->get();

Screen-Shot-2021-05-25-at-15-27-59.pngScreen Shot 2021-05-25 at 15.27.59.png
avatar ddika990

@ddika990

14 Kontribusi 0 Poin


Jawaban

 $tbl = DB::table('leave_form')
        ->select('leave_form.status',
          DB::raw('(CASE WHEN leave_form.status = "Approved" 
                    THEN 2 WHEN leave_form.status = "Rejected" 
                    THEN 1 ELSE 4) as orderingstatus'))
        ->get();
avatar ranialmonk

@ranialmonk

42 Kontribusi 11 Poin


Login untuk gabung berdiskusi