Доброе утро всем
извините за мой плохой английский sh
Я хотел бы преобразовать этот запрос в красноречивый laravel
с учетом того, что минимум и максимальные значения являются динамическими c
Я тестировал много решений, но там я застрял.
Я не остановился по моей просьбе, если у вас есть что-то более элегантное, я Taker.
select
count(pa1.adherent_id) as numb
from polices_assurance as pa1
where
(select SUM(pa1.montant_capital_assure) from polices_assurance as pa2 where pa2.adherent_id=pa1.adherent_id) >= 1 AND
(select SUM(pa1.montant_capital_assure) from polices_assurance as pa2 where pa2.adherent_id=pa1.adherent_id) <= 90000
мой последний тест
$police = \App\Models\PoliceAssurance::where((DB::raw('select SUM(polices_assurance.montant_capital_assure) from polices_assurance as pa2 where pa2.adherent_id=polices_assurance.adherent_id')),'>=', $category->valeur_mini)
->where((DB::raw('select SUM(polices_assurance.montant_capital_assure) from polices_assurance as pa2 where pa2.adherent_id=polices_assurance.adherent_id')),'>=', $category->valeur_max)
->count('adherent_id');
Спасибо за вашу помощь