Hi everyone here is my query for fetching the data of statuses
$all_statuses =array(1,2,3,4,5,6,7,8);
$all_open_wo = WorkOrders::selectRaw('count(*) AS cnt, wo_status')
->whereIn('wo_status', $all_statuses)
->groupBy('wo_status')
->orderBy('wo_status', 'asc')
->get();
I have got the sum of every status of the element in $all_statuses
array. As you can see there are 8 elements in this array and currently in my table only 6 statuses exist. So I get only the sum of rows with those 6 statuses. Can I get "0" for the sum of those statuses which are not existing in the table ?
Thanks
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire