[x]
Posted via EE Mobile

Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again.

Question
[x]
Attachment Details

Need to write a query to extract product info

Asked by Swaminathan_K in Oracle 10.x

Tags: oracle 10g

Hi ,
I have 3 tables called product  , CMF and global_open_item_id . I need to fetch the products which has mismatch in open_item_id by joining both the poduct  and the global_open_item_id table.
The Global_open_Item_id _maptable contains info on the open_item_id  for each product. It has two rows one default row with the charge_element_type and charge_element_value=0 and another
row with the charge_element_type=1 and charge_element_value=<element_id>. The query should pick the default open_item_id if the charge_element_type and charge_element_value does not match a given product , else the matching row open_item_id .

Below is the query i have written to fetch the products with
Select P.element_id , p.Open_item_id , g.open_item_id mismatchid
From Product p,
CMF c ,
Global_open_item_id_map g
Where c.account_no=p.parent_account_no
and g.charge_element_type in (0,1)
and g.charge_element_value in (0, p.element_id)
and g.state=decode(c.cust_state , 'NH',30,'VT',46,'ME',20);
and g.open_item_id <> p.open_item_id

The Expected output should be as below :
element_id   open_item_id  mismatchid
10001792    143                   145

The structure of the CMF table is
AccountNo Number(12)
Cust_state varchar2(3)

Data:
600003   ME


Also attached is the structure and data of Product and global_open_item_id table
Attachments:
 
Data in global Open Item id table
 
 
data in product table
 
 
File containing the DDL for the table product and global open item id tables
 
[+][-]11/06/09 10:17 AM, ID: 25761554Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11/06/09 12:45 PM, ID: 25762883Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11/06/09 07:06 PM, ID: 25764804Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]11/06/09 07:08 PM, ID: 25764812Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20091111-EE-VQP-89 - Hierarchy / EE_QW_3_20080625