sql >> Database teknologi >  >> RDS >> Mysql

php,postgresql,mysql

Prøv dette

select  cont.name, cont.total,cp.contractor_id,cp.amount_paid,wt.id
                FROM
                (
                  select  name,id, sum(amount_to_be_paid) as total
                  from contractors group by name,id
                ) cont
                left join
                (
                  select contractor_id,sum(amount_paid) as amount_paid
                  from contractor_payments
                  group by contractor_id
                ) cp

                  on cont.id = cp.contractor_id
                              left join worktypeids as wt on cont.worktypeid_id = wt.id AND wt.project_id=2


  1. Scrabble ordfinder med jokertegn

  2. Praktiskheden af ​​flere databaser pr. klient vs. én database

  3. Linq to Entities Group By (OUTER APPLY) oracle 11.2.0.3.0 understøtter ikke gælder

  4. IBM Worklight - Hvordan får man OUT-parameteren, når man kalder en lagret procedure?