mardi 8 mai 2018

Query count also non matching values

I have this query which returns matching values.

Availability::select(DB::raw('count(start) as count,start'))
                                    ->whereIn('start', [100,200,300,400])
                                    ->groupBy('start')
                                    ->get();

And returns:

count | start
1     | 100
2     | 200

I want the show in the result also 0 count values. Like:

count | start
1     | 100
2     | 200
0     | 300
0     | 400

Any ideas? Thanks in advance :)



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire