Getting cartesian product

can anyone help in the following query where iam getting cartesian product,so how to get result without cartesian product
this is the query
SELECT DISTINCT MIS.segment1 "ITEM CODE",
MIS.DESCRIPTION "DESCRIP"
,MIS.Primary_uom_code "UOM",
MTL.LOT_NUMBER "LOT NUMBER"
,A.PARTY_NUMBER "CUSTOMER NUMBER",
A.PARTY_NAME "CUSTOMER NAME",
(A.ADDRESS1||A.ADDRESS2||A.ADDRESS3||A.ADDRESS4) "SHIP TO",
B.DELIVERY_DETAIL_ID "DO NO",B.SHIPPED_QUANTITY "SHIPPED QUANTITY"
,C.ULTIMATE_DROPOFF_DATE "ISSUED DATE"
,D.ORDER_NUMBER "SALES ORDER NUMBER"
,E.LINE_NUMBER "SALES ORDER LINE"
FROM MTL_SYSTEM_ITEMS MIS
,MTL_TRANSACTION_LOT_NUMBERS MTL
     ,HZ_PARTIES A,
     WSH_DELIVERY_DETAILS B,
     WSH_NEW_DELIVERIES C,
     OE_ORDER_HEADERS_ALL D,
     OE_ORDER_LINES_ALL E
WHERE MIS.INVENTORY_ITEM_ID=MTL.INVENTORY_ITEM_ID
AND B.INVENTORY_ITEM_ID=MIS.INVENTORY_ITEM_ID
AND A.PARTY_ID=B.CUSTOMER_ID
AND B.DELIVERY_DETAIL_ID=C.DELIVERY_ID
AND MIS.INVENTORY_ITEM_ID=E.INVENTORY_ITEM_ID
AND D.HEADER_ID=E.HEADER_ID

SELECT DISTINCT MIS.segment1 "ITEM CODE",
                MIS.DESCRIPTION "DESCRIP"
                ,MIS.Primary_uom_code "UOM",
                MTL.LOT_NUMBER "LOT NUMBER"
                ,A.PARTY_NUMBER "CUSTOMER NUMBER",
                A.PARTY_NAME "CUSTOMER NAME",
                (A.ADDRESS1||A.ADDRESS2||A.ADDRESS3||A.ADDRESS4) "SHIP TO",
                B.DELIVERY_DETAIL_ID "DO NO",B.SHIPPED_QUANTITY "SHIPPED QUANTITY"
                ,C.ULTIMATE_DROPOFF_DATE "ISSUED DATE"
                ,D.ORDER_NUMBER "SALES ORDER NUMBER"
                ,E.LINE_NUMBER "SALES ORDER LINE"
  FROM          MTL_SYSTEM_ITEMS             MIS,
                MTL_TRANSACTION_LOT_NUMBERS  MTL,
                HZ_PARTIES                   A,
                WSH_DELIVERY_DETAILS         B,
                WSH_NEW_DELIVERIES           C,
                OE_ORDER_HEADERS_ALL         D,
                OE_ORDER_LINES_ALL           E
WHERE          MIS.INVENTORY_ITEM_ID = MTL.INVENTORY_ITEM_ID
   AND          MIS.INVENTORY_ITEM_ID = E.INVENTORY_ITEM_ID
   AND          B.INVENTORY_ITEM_ID   = MIS.INVENTORY_ITEM_ID
   AND          A.PARTY_ID            = B.CUSTOMER_ID
   AND          B.DELIVERY_DETAIL_ID  = C.DELIVERY_ID
AND C........ = D. .......
   AND          D.HEADER_ID           = E.HEADER_ID
;I am not sure but I guess a relationship (in bold) is missing.
HTH
Ghulam

Similar Messages

  • Urgent plz help me out about cartesian product

    plz...its urgent,can anyone help in the following query where iam getting cartesian product,so how to get result without cartesian product
    this is the query
    SELECT DISTINCT MIS.segment1 "ITEM CODE",
    MIS.DESCRIPTION "DESCRIP"
    ,MIS.Primary_uom_code "UOM",
    MTL.LOT_NUMBER "LOT NUMBER"
    ,A.PARTY_NUMBER "CUSTOMER NUMBER",
    A.PARTY_NAME "CUSTOMER NAME",
    (A.ADDRESS1||A.ADDRESS2||A.ADDRESS3||A.ADDRESS4) "SHIP TO",
    B.DELIVERY_DETAIL_ID "DO NO",B.SHIPPED_QUANTITY "SHIPPED QUANTITY"
    ,C.ULTIMATE_DROPOFF_DATE "ISSUED DATE"
    ,D.ORDER_NUMBER "SALES ORDER NUMBER"
    ,E.LINE_NUMBER "SALES ORDER LINE"
    FROM MTL_SYSTEM_ITEMS MIS
    ,MTL_TRANSACTION_LOT_NUMBERS MTL
    ,HZ_PARTIES A,
    WSH_DELIVERY_DETAILS B,
    WSH_NEW_DELIVERIES C,
    OE_ORDER_HEADERS_ALL D,
    OE_ORDER_LINES_ALL E
    WHERE MIS.INVENTORY_ITEM_ID=MTL.INVENTORY_ITEM_ID
    AND B.INVENTORY_ITEM_ID=MIS.INVENTORY_ITEM_ID
    AND A.PARTY_ID=B.CUSTOMER_ID
    AND B.DELIVERY_DETAIL_ID=C.DELIVERY_ID
    AND MIS.INVENTORY_ITEM_ID=E.INVENTORY_ITEM_ID
    AND D.HEADER_ID=E.HEADER_ID

    A lot of times when I get duplicate results, I'll do a select * and see why. Often one of those tables will have a sequenced value that could repeat several times for a combination of values.
    If thats the case, you may need to add something like:
    ...and a.id = (select min(id)
                     from b
                    where a.col = b.col)

  • General algorithm for cartesian product

    i am looking for an algorithm to get the cartesian product from a set of sets like {{1,2,3,4},{a,b,c},{x,y,z,7,15}...} - this means in most general form.
    google yields no results :-(. i think implementing it by myself is not a good idea.

    dermoritz wrote:
    prometheuzz is your algorithm better than n*mi n: number of sets mi: cardinality of the set i ?
    can you short explain the algorithm?You can't do any better than that because for n sets: S(0), S(1), S(2) ... S(n-1) there are prod(i in [0, n), |S(i)|) elements of the caresian product. Prometeuzz algorithm generates
    one at ever pass of the loop executing n steps per element. If you're afraid that the product number will be too large you can also fiddle with the indexes themselves:
    // scard[i] == |S(i)|
    // prod[i] == element of S(i) in product
    int[] next(int[] scard, int[] prod) {
       for (int i= prod.lerngth; i-- > 0; prod= 0)
    if (++prod[i] < scard[i]) return prod; // return indexes of next product
    return null; // no next product anymore
    }kind regards,
    Jos                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • Query having cartesian product

    hi
    i have the following query
    select f.item_number, case when f.item_number='1020101002' then f.calc_cement_sk else f.calc_amount end act
                from XXNP_OPN_JOBLOG_EST_002 F WHERE f.OPN_JOBLOG_001_ID ='6369'
    output
    ITEM_NUMBER     ACT
    1020101001     NULL
    1020111001     NULL
    1020112001     NULL
    1020113004     NULL
    1020101002     494
    1020102007     232
    1020103004     37
    1020104004     557
    1020106002     20896
    1020111001     5
    1020112005     16253
    1020112008     46
    1020113004     40
    1020222010     1393
    ie 14 rows
    another query
    SELECT J.ITEM_NUMBER,j.opn_value  FROM XXNP_OPN_JOBLOG_RES_005 J  WHERE  J.OPN_JOBLOG_001_ID ='6369' 
    output
    ITEM_NUMBER     OPN_VALUE
    1010101003     1
    1010101004     3
    1010101005     2
    1010104016     1
    1010103001     76
    1010103002     228
    1010106001     2
    1010106006     147
    1010107010     1
    1010109009     1
    1010107015     866
    1010107014     799
    1010107016     1631
    ie 13 rows
    when i do
    select f.item_number, case when f.item_number='1020101002' then f.calc_cement_sk else f.calc_amount end act ,j.opn_value
           from XXNP_OPN_JOBLOG_EST_002 F ,XXNP_OPN_JOBLOG_RES_005 J   where   f.OPN_JOBLOG_001_ID = J.OPN_JOBLOG_001_ID and f.OPN_JOBLOG_001_ID ='6369'
    i get 182 rows :( i know its due to cartesian product
    is there any way i can get 27 rows  only ,can i get the output in the format given below
    ITEM_NUMBER     ACT                  opn_value
    1020101001     NULL
    1020111001     NULL
    1020112001     NULL
    1020113004     NULL
    1020101002     494
    1020102007     232
    1020103004     37
    1020104004     557
    1020106002     20896
    1020111001     5
    1020112005     16253
    1020112008     46
    1020113004     40
    1020222010     1393
    1010101003                                                                     1                                                    
    1010101004                                                                     3                                                              
    1010101005                                                                      2
    1010104016                                                                      1
    1010103001                                                                     76
    1010103002                                                                      228
    1010106001                                                                      2
    1010106006                                                                     147
    1010107010                                                                      1
    1010109009                                                                        1
    1010107015                                                                      866
    1010107014                                                                      791
    1010107016                                                                    1631kindly guide
    thanking in advance
    Edited by: makdutakdu on Mar 31, 2011 8:03 AM

    hi
    script for XXNP_OPN_JOBLOG_RES_005
    CREATE TABLE XXNP_OPN_JOBLOG_RES_005
      OPN_JOBLOG_005_ID  NUMBER,
      OPN_JOBLOG_001_ID  NUMBER,
      WIP_ENTITY_ID      NUMBER,
      WIP_ENTITY_NAME    VARCHAR2(240 BYTE),
      OPN_RESOURCE_CODE  VARCHAR2(30 BYTE),
      OPN_UOM_CODE       VARCHAR2(30 BYTE),
      OPN_VALUE          NUMBER,
      OPN_MOV_DATE       DATE,
      ORG_ID             NUMBER(15),
      CREATION_DATE      DATE,
      CREATED_BY         NUMBER(15),
      LAST_UPDATE_DATE   DATE,
      LAST_UPDATED_BY    NUMBER(15),
      LAST_UPDATE_LOGIN  NUMBER(15),
      OPN_RESOURCE_DESC  VARCHAR2(500 BYTE),
      ITEM_PRICE         NUMBER,
      ITEM_NUMBER        NUMBER(10),
      DIS_PER            NUMBER(3),
      EST_VALUE          NUMBER(15,3),
      VAL_ESTAB          NUMBER(15,3)
    script for XXNP_OPN_JOBLOG_EST_002
    CREATE TABLE XXNP_OPN_JOBLOG_EST_002
      OPN_JOBLOG_002_ID   NUMBER,
      OPN_JOBLOG_007_ID   NUMBER,
      INVENTORY_ITEM_ID   NUMBER,
      ITEM_NUMBER         VARCHAR2(20 BYTE),
      ITEM_NAME           VARCHAR2(40 BYTE),
      ITEM_UOM            VARCHAR2(30 BYTE),
      ITEM_VALUE          NUMBER,
      ITEM_PERCENT        NUMBER,
      OPN_AMOUNT          NUMBER,
      ITEM_CEMENT_SK      NUMBER,
      ORG_ID              NUMBER(15),
      CREATION_DATE       DATE,
      CREATED_BY          NUMBER(15),
      LAST_UPDATE_DATE    DATE,
      LAST_UPDATED_BY     NUMBER(15),
      LAST_UPDATE_LOGIN   NUMBER(15),
      OPN_JOBLOG_001_ID   NUMBER,
      OPN_JOBLOG_006_ID   NUMBER,
      ITEM_REF            NUMBER,
      DESCRIPTION         VARCHAR2(500 BYTE),
      CALC_AMOUNT         NUMBER,
      CALC_CEMENT_SK      NUMBER,
      )

  • Cartesian Product from in-line queries

    I have the following query:
    SELECT AUDIT_MONTH, AUDITS, DEFECTS
    FROM
    select distinct(to_char(AUDIT_DATE,'MM/YY')) as AUDIT_MONTH
    from v_safety_audit_records
    select count(distinct(AUDIT_ID)) AUDITS
    from v_safety_audit_records
    group by to_char(AUDIT_DATE,'MM/YY')
    select count(KEY_ID) DEFECTS
    from v_safety_audit_records
    where SUBAREA_ID NOT LIKE '_98'
    and SUBAREA_ID NOT LIKE '_99'
    group by to_char(AUDIT_DATE,'MM/YY')
    but it keeps giving me a cartesian product. Is there a way to re-write this so that I only get the month, the number of audits, and number of defects on a line rather than number of months x number of months worth of lines? I can't seem to get the join conditions worked out... I can re-write this all using views, but as it is for a single report, I'd rather not bother with more views if I can avoid it.
    Thanks in advance.

    The problem is that the query doesn't return a single row and isn't meant to. I tried:
    SELECT
    select distinct(to_char(AUDIT_DATE,'MM/YY'))
    from v_safety_audit_records
    group by to_char(AUDIT_DATE,'MM/YY')
    ) AUDIT_MONTH,
    select count(distinct(AUDIT_ID))
    from v_safety_audit_records
    group by to_char(AUDIT_DATE,'MM/YY')
    ) AUDITS,
    select count(KEY_ID)
    from v_safety_audit_records
    where SUBAREA_ID NOT LIKE '_98'
    and SUBAREA_ID NOT LIKE '_99'
    group by to_char(AUDIT_DATE,'MM/YY')
    ) DEFECTS
    FROM DUAL;
    and got "ORA-01427: single-row subquery returns more than one row". It would be a good idea if I only needed it for one month, however.

  • What is Cartesian product in Oracle?

    "Cartesian product" often appear in the Oracle book, what is it?

    Hi Ashish,
    Actually it is the other way round. Actually it depends the way you see.. But normal it is stated this way.If you want to get data from two tables depending on one condition you use join. If you don't give a condition for joining it displays the cartesian product of the two tables.
    If the condition for joining the table is equality sign then it is called equi join else if it is > or < then non-equi join.
    Similary you have outer join, self join(joining table with itself based on a condition), inner join ,etc.
    To learn more about joins take a look at the following link
    http://download-west.oracle.com/docs/cd/B10501_01/server.920/a96540/queries7.htm
    Regards,
    Anupama

  • View creating Cartesian Product.. why....

    i am joining 5 tables in a view.. dont know exactly why it is creating Cartesian product.
    Below is the query:
    PROMPT CREATE OR REPLACE VIEW xxpd_ozf_aff_err_int_v
    CREATE OR REPLACE VIEW xxpd_ozf_aff_err_int_v (
    row_id,
    source_system,
    source_process_id,
    source_process_date,
    ora_process_id,
    soa_instance_id,
    customer_record_id,
    process_status,
    insert_update_flag,
    process_stage,
    process_start_time,
    process_end_time,
    error_code,
    error_message,
    error_type,
    customer_process_status,
    supplier_process_status,
    customer_level,
    source_customer_ref,
    customer_class_code,
    customer_type,
    business_model_code,
    source_parent_cust_ref,
    source_parent_cust_type,
    customer_name,
    account_status,
    customer_alias,
    person_flag,
    person_first_name,
    person_last_name,
    tax_reg_number,
    tax_reg_type,
    customer_id,
    account_number,
    party_id,
    party_type,
    party_number,
    supplier_id,
    affiliate_type,
    check_payable_name,
    payable_flag,
    approved_flag,
    primary_site,
    site_status,
    purpose,
    address1,
    address2,
    address3,
    address4,
    city,
    county,
    state,
    province,
    postal_code,
    country,
    cust_acct_site_id,
    party_site_id,
    location_id,
    reportable_1099,
    tax_type_1099,
    primary_contact,
    contact_role,
    contact_status,
    first_name,
    last_name,
    salutation,
    job_title,
    email_address,
    phone_line_type,
    phone_number,
    phone_extension,
    phone_area_code,
    phone_country_code,
    preferred_language,
    customer_profile_class,
    profile_acct_status,
    profile_active_status,
    account_status_reason,
    invoice_type
    ) AS
    SELECT acct.ROWID row_id,
    CTRL.SOURCE_SYSTEM,
    CTRL.SOURCE_PROCESS_ID,
    CTRL.SOURCE_PROCESS_DATE,
    CTRL.ORA_PROCESS_ID,
    CTRL.SOA_INSTANCE_ID,
    ACCT.CUSTOMER_RECORD_ID,
    CTRL.PROCESS_STATUS,
    CTRL.INSERT_UPDATE_FLAG,
    CTRL.PROCESS_STAGE,
    CTRL.PROCESS_START_TIME,
    CTRL.PROCESS_END_TIME,
    CTRL.ERROR_CODE,
    CTRL.ERROR_MESSAGE,
    --ACCOUNT TABLE
    ACCT.ERROR_TYPE,
    ACCT.CUSTOMER_PROCESS_STATUS,
    ACCT.SUPPLIER_PROCESS_STATUS,
    ACCT.CUSTOMER_LEVEL,
    ACCT.SOURCE_CUSTOMER_REF,
    ACCT.CUSTOMER_CLASS_CODE,
    ACCT.CUSTOMER_TYPE,
    ACCT.BUSINESS_MODEL_CODE,
    ACCT.SOURCE_PARENT_CUST_REF,
    ACCT.SOURCE_PARENT_CUST_TYPE,
    ACCT.CUSTOMER_NAME,
    ACCT.ACTIVE_STATUS ACCOUNT_STATUS,
    ACCT.CUSTOMER_ALIAS,
    ACCT.PERSON_FLAG,
    ACCT.PERSON_FIRST_NAME,
    ACCT.PERSON_LAST_NAME,
    ACCT.TAX_REG_NUMBER,
    ACCT.TAX_REG_TYPE,
    ACCT.CUSTOMER_ID,
    ACCT.ACCOUNT_NUMBER,
    ACCT.PARTY_ID,
    ACCT.PARTY_TYPE,
    ACCT.PARTY_NUMBER,
    ACCT.SUPPLIER_ID,
    ACCT.AFFILIATE_TYPE,
    ACCT.CHECK_PAYABLE_NAME,
    ACCT.PAYABLE_FLAG,
    ACCT.APPROVED_FLAG,
    --SITE TABLE
    SITE.PRIMARY_FLAG PRIMARY_SITE,
    SITE.ACTIVE_STATUS SITE_STATUS,
    SITE.PURPOSE,
    SITE.ADDRESS1,
    SITE.ADDRESS2,
    SITE.ADDRESS3,
    SITE.ADDRESS4,
    SITE.CITY,
    SITE.COUNTY,
    SITE.STATE,
    SITE.PROVINCE,
    SITE.POSTAL_CODE,
    SITE.COUNTRY,
    SITE.CUST_ACCT_SITE_ID,
    SITE.PARTY_SITE_ID,
    SITE.LOCATION_ID,
    SITE.REPORTABLE_1099,
    SITE.TAX_TYPE_1099,
    --CONTACT
    CONT.PRIMARY_FLAG PRIMARY_CONTACT,
    CONT.CONTACT_ROLE,
    CONT.ACTIVE_STATUS CONTACT_STATUS,
    CONT.FIRST_NAME,
    CONT.LAST_NAME,
    CONT.SALUTATION,
    CONT.JOB_TITLE,
    CONT.EMAIL_ADDRESS,
    CONT.PHONE_LINE_TYPE,
    CONT.PHONE_NUMBER,
    CONT.PHONE_EXTENSION,
    CONT.PHONE_AREA_CODE,
    CONT.PHONE_COUNTRY_CODE,
    CONT.PREFERRED_LANGUAGE,
    --PRO
    PRFL.CUSTOMER_PROFILE_CLASS,
    PRFL.ACCOUNT_STATUS PROFILE_ACCT_STATUS,
    PRFL.ACTIVE_STATUS PROFILE_ACTIVE_STATUS,
    PRFL.ACCOUNT_STATUS_REASON,
    PRFL.INVOICE_TYPE
    FROM XXEX_AR_CUST_INT_CTRL_T CTRL,
    XXEX_AR_CUST_ACCT_INT_T ACCT,
    XXEX_AR_CUST_SITE_INT_T SITE,
    XXEX_AR_CUST_CONTACT_INT_T CONT,
    XXEX_AR_CUST_PROFILE_INT_T PRFL
    WHERE CTRL.ORA_PROCESS_ID = ACCT.ORA_PROCESS_ID
    AND ACCT.CUSTOMER_RECORD_ID = SITE.CUSTOMER_RECORD_ID
    AND SITE.CUSTOMER_RECORD_ID = CONT.CUSTOMER_RECORD_ID
    AND CONT.CUSTOMER_RECORD_ID = PRFL.CUSTOMER_RECORD_ID
    AND acct.Supplier_process_status = 'E'
    How i should join the 6 tables..

    Rashmi Gupta wrote:
    No all table have records corresponding to each customer ID... But what if one of the table has 1 row..?
    I checked the result.. there is a Cartesian product.
    Customer_Record_ID is unique identifier in 4 tables -
    XXEX_AR_CUST_ACCT_INT_T ACCT,
    XXEX_AR_CUST_SITE_INT_T SITE,
    XXEX_AR_CUST_CONTACT_INT_T CONT,
    XXEX_AR_CUST_PROFILE_INT_T PRFL
    XXEX_AR_CUST_INT_CTRL_T CTRL and XXEX_AR_CUST_ACCT_INT_T ACCT tables have ora_process_id column common so joined between them.
    We dont use primary keys in Interface tables.. we are just using unique indentifier
    Edited by: Rashmi Gupta on Jan 30, 2012 5:58 AMAbove is a very well worded version of what I was getting around to, but in the mean time I've been distracted by your "we don't use primary keys"...when you say "unique identifier" please tell me you mean "unique constraint" ?

  • How Cartesian products affects Sybase IQ performance?

    In my IQ message log, I have the following message:
    I. 04/21 08:28:22. 0001847919 Exception Thrown from dfo_Root.cxx:822, Err# 0, tid 8 origtid 8
    I. 04/21 08:28:22. 0001847919 O/S Err#: 0, ErrID: 9216 (df_Exception); SQLCode: -1005015, SQLState: 'QTA15', Severity: 14
    I. 04/21 08:28:22. 0001847919 [20169]: The optimizer was unable to find a query plan that avoided cartesian product joins larger than the Max_Cartesian_Result setting
    -- (dfo_Root.cxx 822) 
    I don´t know if
    this situation may affect the overall performance
    Thank you

    Hi Jairo,
    As Cartesian product (no join conditions) selects large number of rows, it requires more exec time, temp space (if order by, group by, etc,..) , temp cache, main cache, threads.
    To get close estimations about query resources consumtion, you can generate plans without execution using option NoExec.
    Query plan option recommended are : quary_name, query_plan, query_detail, query_plan_as_html, query_plan_as_html_directory, dml_options10.
    See Generating Query Plans
    Note that other resource monitoring options can be enabled/used , but they require effectivel query exection. The info are collected once execution is finished with success. Eg. query_plan_after_run and query_timing.
    Regards,
    Tayeb.

  • Want to avoid cartesian Product but cannot avoid it some how.

    Hi,
    I am using oracle 10G .
    trying to draft a query which is resulting in absurd results.
    select i.corr_acc_no, sum(amtsign.amount_6) from item i,
    (select corr_Acc_no,flag_2,decode(fund_code,'C',amount_6,amount_6*-1) amount_6 from item
    where corr_AcC_no in (select corr_acc_no from bank where local_Acc_no in ('MBL-SEG-NZD'))and flag_2=0) AmtSign
    where i.corr_acc_no=amtsign.corr_acc_no
    and i.flag_2=0
    group by  i.corr_acc_no
    Basically the inner query, which i am using as the second table in the join, gives 13 results. I want to sum the amount_6 field in main select clause which I want to get from results of
    (select corr_Acc_no,flag_2,decode(fund_code,'C',amount_6,amount_6*-1) amount_6 from item
    where corr_AcC_no in (select corr_acc_no from bank where local_Acc_no in ('MBL-SEG-NZD'))and flag_2=0)
    The sum took too much time so i drafted simple query to check how many rows are returned by removing sum and i noticed it gives a Cartesian product with 169 rows instead of just 13. I have 2 join conditions but the value for corr_Acc_no is same for all 13 rows, i can't use amount_6 as join becuase i am changing it's sign  in the inner query. Please advise.

    Thanks to both of you. @LakmalRajapakse your answer is bang on right. I did the same way after I posted this. I realized there's no point joining item with itself when I can get it done in single query. It's just that I was having hard time with 'Case' in select to get whatever I want,so I tried this logic. But then gave a try to decode, it worked. Thanks anyways.

  • CARTESIAN PRODUCT problem

    hello,
    i m trying to find the difference for calculating the DIFFENCE IN STOCK FOR OPC,PPC,CLINKER BY USING FOLLOWING SQL-QUERY
    SELECT TO_CHAR(a.dateofmtrl,'YYYY') YEAR,
    SUM(a.rm1) - SUM(b.rm1) - SUM(c.rm1) OPC,
    SUM(a.rm2) - SUM(b.rm2) - sum(c.rm2) PPC,
    SUM(a.rm3) - SUM(b.rm3) - sum(c.rm3) CLINKER
    FROM rawmtrl_graph a
    INNER JOIN rawmtrl_graph b ON TO_CHAR(a.dateofmtrl,'YYYY') =TO_CHAR(B.dateofmtrl,'YYYY')
    INNER JOIN rawmtrl_graph c ON TO_CHAR(a.dateofmtrl,'YYYY') =TO_CHAR(C.dateofmtrl,'YYYY')
    WHERE a.mtrl_flag='P'
    AND b.mtrl_flag='D'
    AND c.mtrl_flag='CS'
    GROUP BY TO_CHAR(a.dateofmtrl,'YYYY')
    BUT IT IS GIVING CARTESIAN PRODUCT...
    HOW TO MODIFY THE QUERY FOR FINDING EXACT FIGURE??????
    THANKS IN ADVENCE FOR ANY HELP.....

    Hi,
    please always put your code between two lines starting with {noformat}{noformat}.
    Additionally when you put insert statement put them entirely and not copying from one table we don't have.
    Here the way to get the result you want:SELECT EXTRACT(YEAR FROM dateofmtrl) yr
    , SUM(CASE mtrl_flag WHEN 'P' THEN rm1 ELSE -rm1 END) AS opc
    , SUM(CASE mtrl_flag WHEN 'P' THEN rm2 ELSE -rm2 END) AS ppc
    , SUM(CASE mtrl_flag WHEN 'P' THEN rm3 ELSE -rm3 END) AS clinker
    FROM rawmtrlgraph
    GROUP BY EXTRACT(YEAR FROM dateofmtrl);
    YR OPC PPC CLINKER
    2011 50 54 55
    2012 -49 -3 -11
    Regards.
    Al                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • Cartesian Product with @SumRange

    Hi,
    I'm trying to calculata a sumRange of an Account on two separate Dimension,on Planning 11.1.2.3
    @sumRange("Account"->"ToTal",@Range("Dimension1.1"->"Dimension2.3","Dimension1.3"->"Dimnension2.5"));
    the results is not what i was expecting, The target would be a Cartesian Product ( sum of the following elements) :
    Dimension1.1"->"Dimension2.3
    Dimension1.1"->"Dimension2.4
    Dimension1.1"->"Dimension2.5
    Dimension1.2"->"Dimension2.3
    Dimension1.2"->"Dimension2.4
    Dimension1.2"->"Dimension2.5
    Dimension1.3"->"Dimension2.3
    Dimension1.3"->"Dimension2.4
    Dimension1.3"->"Dimension2.5
    Is there any ways to achieve this ?
    Regards

    Hi,
    thanks for your eeply but the @Xrange will get  also elements that are not needed.
    if Dimension 1 has got 20 childrens (Dimension 1.1 ...Dimension 1.20) the calc will add all these elements :
    Dimension1.1"->"Dimension2.3
    Dimension1.2"->"Dimension2.3
    Dimension1.20"->"Dimension2.3
    Dimension2.1"->"Dimension2.4
    Dimension2.20"->"Dimension2.4
    Dimension1.3"->"Dimension2.3
    Dimension1.3"->"Dimension2.4
    Dimension1.3"->"Dimension2.5
    and that is incorrect.
    The elements that are needed are those in the first post.
    Regards

  • Hint ordered and cartesian product

    I have a query which needs to be tuned.
    The initial Query does not show cartesian product in the plan , when I change the order of the tables in the from clause ( I have placed the least # of rows first and the most rows tables in the last) and I get MERGE JOIN CARTESIAN product the where clause remaining the same and the cost escalates from 7180 to 454M .
    This happens with ordered hint.

    ranjus wrote:
    I have a query which needs to be tuned.
    The initial Query does not show cartesian product in the plan , when I change the order of the tables in the from clause ( I have placed the least # of rows first and the most rows tables in the last) and I get MERGE JOIN CARTESIAN product the where clause remaining the same and the cost escalates from 7180 to 454M .
    This happens with ordered hint.Let's take a look at this with a simple test case. Assume that:
    * Table T1 contains 10,000 rows
    * Table T2 contains 100 rows
    * Table T3 contains 100,000 rows
    * Table T4 contains 10 rows
    You have the following query:
    SELECT
      T1.C1,
      T2.C2,
      T3.C3,
      T4.C4
    FROM
      T1,
      T2,
      T3,
      T4
    WHERE
      T1.C1=T2.C2
      AND T2.C2=T3.C2
      AND T3.C3=T4.C3;In the above, you can see that in the WHERE clause:
    * Table T1 is joined to table T2
    * Table T2 is joined to tables T1 and T3
    * Table T3 is joined to tables T2 and T4
    * Table T4 is joined to table T3
    What it sounds like you are trying to do is something like this based on the number of rows in the tables:
    SELECT /*+ ORDERED */
      T1.C1,
      T2.C2,
      T3.C3,
      T4.C4
    FROM
      T4,
      T2,
      T1,
      T3
    WHERE
      T1.C1=T2.C2
      AND T2.C2=T3.C2
      AND T3.C3=T4.C3;In the above, we are forcing Oracle's optimizer to join tables T4 and T2 - but there is no direct relationship between the two tables described in the WHERE clause. In such a case, Oracle's optimizer will be forced to perform a Cartesian join between tables T4 and T2. Next, table T1 has a relationship defined in the WHERE clause with table T2, so that join would not result in a Cartesian product. Finally, table T3 has a relationship between tables T2 and T4, so that would not result in a Cartesian product.
    Going back to this example, assume that table T4 contained a single row. The execution plan will still show a Cartesian join, but that Cartesian join is no worse than a nested loops join because there is a single row in one of the row sources.
    In short, think about what you are attempting to force the optimizer to do. You cannot always join in the order of increasing row cardinality estimates - it simply does not make sense to try in some cases.
    Charles Hooper
    Co-author of "Expert Oracle Practices: Oracle Database Administration from the Oak Table"
    http://hoopercharles.wordpress.com/
    IT Manager/Oracle DBA
    K&M Machine-Fabricating, Inc.

  • What is the use of Cartesian Product or Cross join?

    Dear friends...
        I have done with inner join, self join and outer join. But I m getting confused with cross join. I know it used to produce Cartesian product of two table. But I wanted to know what is the use of Cartesian product in real life? In
    which situation we can use Cartesian product or cross join? I wanted some real life examples on Cartesian product. Please help me.

    Sometimes you get requirement stating that all combinations should be considered and in this scenario CROSS JOIN comes in play.
    If you have Products and Stores table, by using CROSS JOIN you can get the combination of all stores and all products and then you can JOIN this result set to other tables.
    Please refer:  The power of the Cross Join
    Cheers,
    Vaibhav Chaudhari
    [MCTS],
    [MCP]

  • Joins between two tables generating Cartesian product

    Hi All,
        I am facing an issue in my report in which, I am getting mismatch as the two subsets which I'm joining is resulting in a cartesian product of individual subset's results. I am doing left join to join those two subsets. Please help in resolving
    this issue. 
    Thank you,
    Anu.

    Hi,
    Can you please post your script to see what is causing the cartesian product?
    This way it is difficult to help you.
    Regards,
    Reshma
    Please Vote as Helpful if an answer is helpful and/or Please mark Proposed as Answer or Mark As Answer when question is answered

  • I have just sought  to update my lightroom and am now unable to access the develop function and get a note stating that I have reduced functionality what it this about and how do I get my product back

    I have just sought  to update my lightroom and am now unable to access the develop function and get a note stating that I have reduced functionality what it this about and how do I get my product back

    Hi there
    I have version 5.7 and every time I opened it I was told that updates are available and to click on the icon to access these.  Instead it just took me to the
    adobe page with nowhere visible to update.  I then  sought to download lightroom cc and this is when I could not access the 'develop' section due to reduced
    functionality  It was apparent that my photos had been put in cc but no way to access them unless I wanted to subscribe. 
    I have since remedied the problem as  my original lightroom 5.7 icon is still available on the desktop and have gone back to that.  I do feel that this is a bit
    of a rip off and an unnecessary waste of my time though.
    Thank you for your prompt reply by the way.
    Carlo
    Message Received: May 04 2015, 04:52 PM
    From: "dj_paige" <[email protected]>
    To: "Carlo Bragagnolo" <[email protected]>
    Cc:
    Subject:  I have just sought  to update my lightroom and am now unable to access the develop function and get a note stating that I have
    reduced functionality what it this about and how do I get my product back
    dj_paige  created the discussion
    "I have just sought  to update my lightroom and am now unable to access the develop function and get a note stating that I have reduced functionality what it
    this about and how do I get my product back"
    To view the discussion, visit: https://forums.adobe.com/message/7510559#7510559
    >

Maybe you are looking for

  • PO Changeability / Release Strategy / BAPI_PO_RELEASE Issue

    Hello everyone, I've run into an interesting problem: We have defined several PO release strategies.  Most of these work in the traditional manner, requiring manual approval by a given user.  One release strategy, "99," gets picked up by a batch job

  • How to shuffle albums with iTunes Remote?

    I fall in love with iTunes Remote on my iPhone. However, one feature, which i love from iTunes is missing there. I'm not able to shuffle albums. Not songs in one album, but to let iTunes randomly play albums one after another from my Library. On Mac,

  • What format is best to choose for importing to iTunes 11?

    Trying to import all my music from Windows XP laptop, (can't find my original CDs, packed away) hours later I found they were in WMA format, not acceptable to iTunes in new Mac Mini, What the? Tell me best choice for format, please? I wasn't thrilled

  • MM functional/Technical

    Hi Industry gurus I am confused.suppose there is question"How can I extend all material to a new plant? This question belong to technical side or function side and why? I will appreciate the response for the same.

  • Make DW use JS code-coloring instead of PHP

    I have a Javascript file that has a .php extension because of some dynamic elements on the page. I also can't wrap the code in <script> tags because of the way it loads. So basically, I need to tell DW to use JS code coloring on this page instead of