Top N reporting based on customer revenues
Query
select qry.party_name, qry.revenue, dense_rank() over (order by qry.revenue desc) as rank
from
(select (select party_name from hz_parties p, hz_cust_accounts ca where ca.party_id = p.party_id and cust_account_id = ps.customer_id) party_name
, sum(amount_due_original) revenue
from ar_payment_schedules_all ps
where class = 'INV'
group by ps.customer_id) qry
Comments
Post a Comment