I am trying to come up with a Oracle view , I am ok with the first part as you see below. (Only pasting part of the syntax here for ease). the issue is that , in order to get the sales manger info, I have to extract it from CUST_KNVP table for which there is another sql syntax i am using. My problem is to combine both these syntax below into one. Can anyone please guide me on this. As you will see tables deliver and Orders appear in both syntax. Thanks
**
/*Main View Sql syntax*/
select
d.gate_entry_date
k.account_exec_name,
o.load_start_date,
o.local_end_date,
d.local_arrival_date,
p.freight,
d.actual_gate_entry_date,
m.shipm_start,
m.shipment_end
from deliver d, ship_pickup_date o, key_customer k,
reel_date m, orders p,
where d.item = m.order_item
and d.sold_to = k.sold_to
and d.shipment_number = o.ship_id
and d.sales_doc = p.sales_doc
and d.item = p.item
/* SQL syntax to get the sales manager below, need to combine both as final product.*/
select sales_manager
from (
select distinct d.sold_to, p.sales_district, d.sales_office, d.sales_rep
from deliver d, orders p
where d.sales_doc = p.sales_doc
and d.item = p.item) driver, cust_knvp mgr
where driver.sold_to = mgr.customer
and driver.sales_district = mgr.sales_district
and driver.sales_office = mgr.sales_office
and driver.sales_rep = mgr.sales_rep
Looking for help, thanks.
cust_knvpin the first part, and forget about the second part?