I have 2 tables which have been joined.
Table : affiliate
Fields : company,affid
+---------------------------+
|company|affid |
|Test1 | t1 |
|Test1 | t2 |
Table : applicant
Fields : affid,commission
+---------------------------+
|affid |commission |
|t1 | 25 |
|t2 | 30 |
Each company has for example 2 affid's.
So company name : Test1
Has affid : t1,t2
What i am trying to do is pull a table that shows the company name and its total commission.
+---------------------------+
|company|commission|
|Test1 | 55 |
This is what i have , what changes do i need to make ?
$data = DB::table('applicant')
->join('affiliate','applicant.affid','=','affiliate.affid')
->select(DB::raw('company,SUM(commission) as commission,'))
->groupBy('company')
->get();
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire