you ca us this code
$mat=$this->Materiel->Paiement->query("
select *,materiel_id , SUM(paiements.quantite) as t from paiements ,materiels
where paiements.materiel_id=materiels.id
GROUP BY
materiel_id
ORDER BY sum(paiements.quantite) desc
");
Ajust this code for your model
1
solved execute query with cakephp [closed]