You would do just as well getting both and order by active.
Otherwise do one or the other separate.
Summer Sale! All accounts are 50% off this week.
I currently have the following query:
UserData::select(
country,
city,
DB::raw('SUM(CASE WHEN end_date IS NULL THEN 1 ELSE 0 END) AS active'),
DB::raw('SUM(CASE WHEN end_date IS NULL THEN 0 ELSE 1 END) AS not_active')
)
->whereBetween('created_at', [Carbon::now()->subYear(), Carbon::now()])
->groupBy('country', 'city')
But I need only the not_active sum to use the whereBetween clause, Is it possible to do it in the same query ?
Please or to participate in this conversation.