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

avatar ddika990
@ddika990

14 Kontribusi 0 Poin

Diperbarui 3 tahun yang lalu

Tanggapan

gambarnya burem

1 Jawaban:

<pre> $tbl = DB::table('leave_form') -&gt;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')) -&gt;get();</pre>

avatar ranialmonk
@ranialmonk

42 Kontribusi 11 Poin

Dipost 3 tahun yang lalu

Login untuk ikut Jawaban