sql - How to get the sales and collection amount values from a query in Oracle -
hello please have @ query below , see problem oracle query.i have used 2 tables named bill_mas , remit_bill.would appreciate much.
query :
select x.sc_cd, x.rm_id, x.fm_id, x.bill_no, x.deli_dt, x.sale_net, y.rmt, y.coll ( select sc_cd, rm_id, fm_id, bill_no, deli_dt, sum(sale_net) sale_net bill_mas deli_dt between '01-feb-15' , '28-feb-15' , bill_no = '754105' , sc_cd = '09' , sale_cd not in ('rs','in','ex') having round(sum(sale_net),2) <= 1000 group sc_cd, rm_id, fm_id, bill_no, deli_dt ) x, ( select p.sc_cd, max(rmt_dt) rmt, sum(p.coll_amt) coll remit_bill p p.bill_no = '754105' , p.rmt_dt = ( select max(rmt_dt) remit_bill p2 p2.bill_no = p.bill_no , sc_cd = '09' ) group p.sc_cd, p.rmt_dt,p.coll_amt ) y x.bill_no = y.bill_no , x.sc_cd = y.sc_cd order 1
error message :
where x.bill_no=y.bill_no * error @ line 18: ora-06553: pls-306: wrong number or types of arguments in call 'ogc_y'
tables :
sql> sql> desc bill_mas name null? type ------------------------------- -------- ---- bill_no not null varchar2(6) bill_dt not null date order_no varchar2(6) order_dt date fp_id not null varchar2(5) sc_cd not null varchar2(2) dist_cd varchar2(2) tha_cd varchar2(2) un_cd varchar2(3) cl_id varchar2(3) sale_cd not null varchar2(2) sale_gr not null number(10,2) sale_net not null number(10,2) deli_dt date fl_mvh varchar2(1) user_cd varchar2(2) w_dt date cancl varchar2(1) b_vat number(9,2) rm_id varchar2(5) fm_id varchar2(5) bs_cd varchar2(4) c_typ varchar2(1) coll_typ varchar2(1) sql> desc remit_bill name null? type ------------------------------- -------- ---- sc_cd not null varchar2(2) rmt_no not null varchar2(6) rmt_dt date bill_no not null varchar2(6) coll_amt not null number(10,2) sql>
query date column p.rmt_dt :
select t1.bill_no, t2.sc_cd, t2.rmt, t2.coll remit_bill t1 inner join ( select p.sc_cd sc_cd, max(rmt_dt) rmt, sum(p.coll_amt) coll remit_bill p --where p.bill_no = '754105' p.rmt_dt = ( select max(rmt_dt) remit_bill p2 p2.bill_no = p.bill_no , sc_cd = '09' , p.rmt_dt between '01-feb-15' , '28-feb-15' ) group p.sc_cd, p.rmt_dt,p.coll_amt ) t2 on t1.sc_cd = t2.sc_cd , t1.rmt_dt = t2.rmt
your outermost where
clause referencing column bill_no
in inner query y
, inner query never selected column, suspect won't available. make bill_no
column available, can join
remit_bill
table onto in y
query , carry on were. try changing query this:
select x.sc_cd, x.rm_id, x.fm_id, x.bill_no, x.deli_dt, x.sale_net, y.rmt, y.coll ( select sc_cd, rm_id, fm_id, bill_no, deli_dt, sum(sale_net) sale_net bill_mas deli_dt between '01-feb-15' , '28-feb-15' , bill_no = '754105' , sc_cd = '09' , sale_cd not in ('rs','in','ex') having round(sum(sale_net),2) <= 1000 group sc_cd, rm_id, fm_id, bill_no, deli_dt ) x, ( select t1.bill_no, t2.sc_cd, t2.rmt, t2.coll remit_bill t1 inner join ( select p.sc_cd sc_cd, max(rmt_dt) rmt, sum(p.coll_amt) coll remit_bill p p.bill_no = '754105' , p.rmt_dt = ( select max(rmt_dt) remit_bill p2 p2.bill_no = p.bill_no , sc_cd = '09' ) group p.sc_cd, p.rmt_dt,p.coll_amt ) t2 on t1.sc_cd = t2.sc_cd , t1.rmt_dt = t2.rmt t1.bill_no = '754105' ) y x.bill_no = y.bill_no , x.sc_cd = y.sc_cd order 1
Comments
Post a Comment