|
select C.corporate_setid,
C.corporate_cust_id,
C.name1,
c.roleuser,
sum(D.bal_amt),
O.cr_limit,
O.cr_limit_corp,
O.cr_limit_rev_dt,
O.cr_limit_range,
C.currency_cd
from ps_customer C, ps_cust_data D,
PS_CUST_CREDIT O
where c.cust_status = 'A' and
c.bill_to_flg = 'Y' and
c.cust_level <> 'P' and
C.setid = ( SELECT setid
from ps_set_cntrl_rec
where setcntrlvalue = D.business_unit
and recname = 'CUSTOMER' )
and C.cust_id = D.cust_id
and O.setid = C.corporate_setid
and O.cust_id = C.corporate_cust_id
and O.effdt = ( select max(effdt)
from PS_CUST_CREDIT
where setid = O.setid
and cust_id = O.cust_id
and effdt <= %currentdatein
and eff_status = 'A' )
group by
C.corporate_setid,
C.corporate_cust_id,
C.name1,
C.roleuser,
O.cr_limit,
O.cr_limit_corp,
O.cr_limit_rev_dt,
O.cr_limit_range,
C.currency_cd
|