Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- select sum(payment.amount), count(payment.id), sum(payment.amount)/count(payment.id) as "Average Transaction", staff_org.shortname as "Payment Library", usr_org.shortname as "User Home Library"
- from money.cash_payment payment
- join money.billable_xact bills on bills.id = payment.xact
- join actor.usr usr on usr.id = bills.usr
- join actor.org_unit aoux on aoux.id = usr.home_ou
- join actor.org_unit usr_org on usr_org.id = aoux.parent_ou
- join actor.usr usr2 on usr2.id = payment.accepting_usr
- join actor.org_unit aouy on aouy.id = usr2.home_ou
- join actor.org_unit staff_org on staff_org.id = aouy.parent_ou
- where staff_org.id != usr_org.id
- group by 4, 5
- order by 4, 5
- ;
- select sum(payment.amount), count(payment.id), trunc(sum(payment.amount)/count(payment.id),2) as "Average Transaction", staff_org.shortname as "Payment Library"
- from money.cash_payment payment
- join money.billable_xact bills on bills.id = payment.xact
- join actor.usr usr on usr.id = bills.usr
- join actor.org_unit aoux on aoux.id = usr.home_ou
- join actor.org_unit usr_org on usr_org.id = aoux.parent_ou
- join actor.usr usr2 on usr2.id = payment.accepting_usr
- join actor.org_unit aouy on aouy.id = usr2.home_ou
- join actor.org_unit staff_org on staff_org.id = aouy.parent_ou
- where staff_org.id != usr_org.id
- group by 4
- order by 4
- ;
Add Comment
Please, Sign In to add comment