I have one main table and 2 tables, one is the internal table and the other is the issue_return_broken table. all 3 tables are linked using ITEM_CODE (primary key). if I run less than 3 queries,
Basic request:
select item_code, item_name , item_spec, item_quantity,item_unitprice,item_value from
ven_inv_partmaster
where item_code ='NAVTES13'
Request 1:
select entry_date, quantity_in from ven_inv_inwardmaster
where item_code ='NAVTES13'
group by entry_date,quantity_in
request 2:
select issue_date, issue_qnty,rtn_qnty,brkn_qnty from ven_inv_ibrmaster_log ibrlog
where ibrlog.item_code ='NAVTES13' and issue_dateid !=0
group by issue_date,issue_qnty,rtn_qnty,brkn_qnty
Request 3:
select rtn_date, rtn_qnty,brkn_qnty from ven_inv_ibrmaster_log ibrlog
where ibrlog.item_code ='NAVTES13' and issue_dateid =0
group by rtn_date,rtn_qnty,brkn_qnty
I get the output as below
item_code item_name item_spec item_quantity item_unitprice item_value
NAVTES13 NAVIN TEST13 175 15.00 2175.00
output1:
entry_date quantity_in
2012-04-01 00:00:00.000 50
2012-04-05 00:00:00.000 50
output 2:
issue_date issue_qnty rtn_qnty brkn_qnty
2012-04-02 00:00:00.000 25 0 0
2012-04-10 00:00:00.000 10 0 0
pin 3:
rtn_date rtn_qnty brkn_qnty
2012-04-05 00:00:00.000 10 0
2012-04-10 00:00:00.000 9 6
I need to combine all of these queries into one query and require a result set like this.
Date Quantity_Inward Quantity_Issued Return_Quantity Broken_Quantity
1/4/2012 50 0 0 0
2/4/2012 0 25 0 0
5/4/2012 0 0 10 0
5/4/2012 50 0 0 0
10/4/2012 0 0 9 6
10/4/2012 0 10 0 0
please help me resolve this issue.
internal and ib-master table:
