Advertisement
Guest User

Untitled

a guest
Apr 22nd, 2019
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.49 KB | None | 0 0
  1. select pr.id, coalesce(acc_bal.balance,0.00) as "Amount Paid",
  2. pr.title as "Project Title",
  3. (select coalesce(sum(amount),0.00) from pledge where project_id = pr.id) as "Amount Pledged",
  4. (select count(*) from pledge where project_id = pr.id) as "Pledge count",
  5. (select count(*) from account_history where account_id = acc.id) as "Payment count"
  6. from project pr
  7. join account acc
  8. on pr.id = acc.project_id
  9. left join account_balance acc_bal
  10. on acc.id = acc_bal.account_id
  11. where pr.is_deleted = 0;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement