Forcing full outer join between two facts according to common dimensions

Hi everyone,I have an issue with the way obiee "joins" 2 fact tables regarding according to common dimensions.
Let's assume 2 fact tables F1 and F2 and 2 dimension D1 and D2.
Fi is joined to Dj thanks to IDs.
F1 and F2 have got aggregates sum(mes1), respectively sum(mes2).
The group by is performed on dim1 for D1 and dim2 for D2.
The following 2 queries work fine...but separately:
select dim1, dim2, sum(mes1) from F1, D1, D2 where ... group by dim1, dim2; //7 lines
select dim1, dim2, sum(mes2) from F2, D1, D2 where ... group by dim1, dim2; //8 lines
When I try to select dim1, dim2, sum(mes1) and sum(mes2), the following sql is created by the BI server:
WITH SAWITH0 AS (
select dim1, dim2, sum(mes1) c3 from F1, D1, D2 where ... group by dim1, dim2
), SAWITH1 AS (
select dim1, dim2, sum(mes2) c3 from F2, D1, D2 where ... group by dim1, dim2
select ... dim1,
     ... dim2,
     ... SAWITH0.c3,
     ... SAWITH1.c3
FROM SAWITH0 LEFT OUTER JOIN SAWITH1
     on SAWITH0.dim1=SAWITH1.dim1 and SAWITH0.dim2=SAWITH1.dim2
I get only 7 lines. It means I miss one line from the second query on F2.
The solution is to perform a full outer join. (I tried in TOAD and changing LEFT by FULL is ok)
How can I force the full outer join?
Thanks a lot!

If you use the fact vertical capabilities of OBIEE, it will normally perform a full outer join :
http://gerardnico.com/wiki/dat/obiee/logical_sql/obiee_full_outer_join
Check here for an example (replace the fact cross join by your second fact table F2)
http://gerardnico.com/wiki/dat/obiee/bi_server/design/obiee_densification_design_preservation_dimension
Cheers
Nico

Similar Messages

  • Multiple 'logical joins' between a fact table and one dimension table

    It appears that one cannot create multiple ‘logical joins’ between a fact table and one dimension table in OBIEE using the Oracle BI Administration Tool. For example, considering a Business Model with a dimension table TIMES and a fact table FACT containing START_TIME and END_TIME, we would like to create separate logical joins from FACT to TIMES for the START_TIMEs and END_TIMEs? Obviously, the underlying foreign keys can be created, but as far as I can tell the Oracle BI Administration Tool doesn’t support this. The workaround would be to replicate the TIMES table, but that’s ugly.
    I seek an alternative approach.

    Try this. Create an two aliases for the TIMES dimension (Start & End) in the Physical Layer and then remove foreign key to the "Parent" Times dimension. Create the Foreign Key in the Physical Layer to the new aliases and then create the complex joins in the BMM Layer to the new aliases as well. This will allow you to present both dates within the same table in the Presentation Layer. Not the most elegant solution but it works.

  • Outer join between two Contexts not working

    Hi,
    I have two contexts. A Context and B Context. To define hierachy or to show the both contexts data in single table/report in Web-I, i joined main tables of both contexts with a join. In those main two tables i want to show the table1 data irrespective of corresponding data exist in second table.
    To solve that i tried LEFT/RIGHT outer joins but nothing solved my prob. Because of those were in different context, I suppose. But it's not the same case when i work within a context (Single).
    Hope you got my prob now...!! Please help me out...
    Thank You!!

    Thanks Rohit for your reply.
    Nope, i can't cpntinue without having that join between those two tables. It must be there to get the exact results.
    It's not the prob of using Merged Dimensions... those are useful for another purpose. In my case those two Dimensions have different sets of data and have relation between those two.
    Like:
    Tab-1------Tab2
    Prod1------Cat1
    Prod1------Cat2
    Prod2------Cat3
    Prod3------Cat4
    Prod4------(NULL)
    As per requirement i should show the row for empty, in my ex it's in Prod4.
    If i use two SQL's prob:
    I can't relate those two and which have relation more over interdependent. Shows data as two separate tables in report.
    If i use multiple dataproviders:
    Prob Tab2 is has other joins with other tables to complete the project hierarchy.
    Hope you got it...
    Thank You!!

  • Fact vertical capabilities - Full outer Join - How to?

    Hi,
    I have the same problem described in another post: Forcing full outer join between two facts according to common dimensions
    I will use the same example:
    Let's assume 2 fact tables F1 and F2 and 2 dimension D1 and D2.
    Fi is joined to Dj thanks to IDs.
    F1 and F2 have got aggregates sum(mes1), respectively sum(mes2).
    The group by is performed on dim1 for D1 and dim2 for D2.
    The following 2 queries work fine...but separately:
    select dim1, dim2, sum(mes1) from F1, D1, D2 where ... group by dim1, dim2; //7 lines
    select dim1, dim2, sum(mes2) from F2, D1, D2 where ... group by dim1, dim2; //8 lines
    When I try to select dim1, dim2, sum(mes1) and sum(mes2), the following sql is created by the BI server:
    WITH SAWITH0 AS (
    select dim1, dim2, sum(mes1) c3 from F1, D1, D2 where ... group by dim1, dim2
    ), SAWITH1 AS (
    select dim1, dim2, sum(mes2) c3 from F2, D1, D2 where ... group by dim1, dim2
    select ... dim1,
    ... dim2,
    ... SAWITH0.c3,
    ... SAWITH1.c3
    FROM SAWITH0 LEFT OUTER JOIN SAWITH1
    on SAWITH0.dim1=SAWITH1.dim1 and SAWITH0.dim2=SAWITH1.dim2
    I get only 7 lines. It means I miss one line from the second query on F2.
    The solution is to perform a full outer join between both queries..
    The reply was a link to fact vertical capabilities of OBIEE
    (http://gerardnico.com/wiki/dat/obiee/logical_sql/obiee_full_outer_join)
    (http://gerardnico.com/wiki/dat/obiee/bi_server/design/obiee_densification_design_preservation_dimension)
    In this post the solution is to add a dummy fact table to force a crossjoin.
    This solution don't work in my case because I don't need to return all the members of the dimension, I just need to return the dimension member that are joined to both facts..
    if in the example, the dimension have 20 member with the fact vertical capabilities solution my reports will show 20 rows... and I only want to see 8 rows...
    Any Idea?
    Thanks...

    I found what was the real problem:
    I have two diferent physical and logical Facts with 4 common dimensions and 1 dimesion that only affect to the second fact.
    In my report I'm filtering for this last dimension so the OBI use this query (the more restrictive) and made a left join with the second result...
    The problem is what I need is filter only by the column, but I cant do it because I'm using a column selector and I can't do a FILTER USING statement using a dashboard prompt...
    Any Idea?
    Thanks

  • Removing full outer joins

    Hi All,
    I am creating reports from two fact tables. However, in spite of using only inner joins in RPD, obiee is generating full outer joins between two WITH (sub-query factoring) . Is there a way to enforce inner joins.
    Thanks
    Surya

    872073 wrote:
    All the joins in RPD are inner joins. The query generated is similar as follows. The full outer join is automatically created between SAWITH0 SAWITH1
    WITH
    SAWITH0 AS (SELECT sum(T245.QUANTITY_SOLD) AS c1,
    T161.CHANNEL_DESC AS c2
    FROM
    SH.CHANNELS T161,
    SH.SALES T245
    WHERE ( T161.CHANNEL_ID = T245.CHANNEL_ID )
    GROUP BY T161.CHANNEL_DESC),
    SAWITH1 AS (SELECT sum(T168.UNIT_COST) AS c1,
    T161.CHANNEL_DESC AS c2
    FROM
    SH.CHANNELS T161,
    SH.COSTS T168
    WHERE ( T161.CHANNEL_ID = T168.CHANNEL_ID )
    GROUP BY T161.CHANNEL_DESC)
    SELECT DISTINCT case when SAWITH1.c2 IS NOT NULL then SAWITH1.c2 when SAWITH0.c2 IS NOT NULL then SAWITH0.c2 end AS c1,
    SAWITH0.c1 AS c2,
    SAWITH1.c1 AS c3
    FROM
    SAWITH0 FULL OUTER JOIN SAWITH1 ON SAWITH0.c2 = SAWITH1.c2
    ORDER BY c1
    If I change the underlined FULL OUTER JOIN above to just "JOIN", the query returns what I want.
    Edited by: 872073 on Oct 24, 2012 1:14 PMCheck to see if PERF_PREFER_INTERNAL_STITCH_JOIN was turned off in the DB Features.ini file
    The path to the file is Oracle/Middleware/instances/instance1/config/OracleBIServerComponent/coreapplication_obis1/DBFeatures.INI

  • [8i] Need help with full outer join combined with a cross-join....

    I can't figure out how to combine a full outer join with another type of join ... is this possible?
    Here's some create table and insert statements for some basic sample data:
    CREATE TABLE     my_tab1
    (     record_id     NUMBER     NOT NULL     
    ,     workstation     VARCHAR2(4)
    ,     my_value     NUMBER
         CONSTRAINT my_tab1_pk PRIMARY KEY (record_id)
    INSERT INTO     my_tab1
    VALUES(1,'ABCD',10);
    INSERT INTO     my_tab1
    VALUES(2,'ABCD',15);
    INSERT INTO     my_tab1
    VALUES(3,'ABCD',5);
    INSERT INTO     my_tab1
    VALUES(4,'A123',5);
    INSERT INTO     my_tab1
    VALUES(5,'A123',10);
    INSERT INTO     my_tab1
    VALUES(6,'A123',20);
    INSERT INTO     my_tab1
    VALUES(7,'????',5);
    CREATE TABLE     my_tab2
    (     workstation     VARCHAR2(4)
    ,     wkstn_name     VARCHAR2(20)
         CONSTRAINT my_tab2_pk PRIMARY KEY (workstation)
    INSERT INTO     my_tab2
    VALUES('ABCD','WKSTN 1');
    INSERT INTO     my_tab2
    VALUES('A123','WKSTN 2');
    INSERT INTO     my_tab2
    VALUES('B456','WKSTN 3');
    CREATE TABLE     my_tab3
    (     my_nbr1     NUMBER
    ,     my_nbr2     NUMBER
    INSERT INTO     my_tab3
    VALUES(1,2);
    INSERT INTO     my_tab3
    VALUES(2,3);
    INSERT INTO     my_tab3
    VALUES(3,4);And, the results I want to get:
    workstation     sum(my_value)     wkstn_name     my_nbr1     my_nbr2
    ABCD          30          WKSTN 1          1     2
    ABCD          30          WKSTN 1          2     3
    ABCD          30          WKSTN 1          3     4
    A123          35          WKSTN 2          1     2
    A123          35          WKSTN 2          2     3
    A123          35          WKSTN 2          3     4
    B456          0          WKSTN 3          1     2
    B456          0          WKSTN 3          2     3
    B456          0          WKSTN 3          3     4
    ????          5          NULL          1     2
    ????          5          NULL          2     3
    ????          5          NULL          3     4I've tried a number of different things, googled my problem, and no luck yet...
    SELECT     t1.workstation
    ,     SUM(t1.my_value)
    ,     t2.wkstn_name
    ,     t3.my_nbr1
    ,     t3.my_nbr2
    FROM     my_tab1 t1
    ,     my_tab2 t2
    ,     my_tab3 t3
    ...So, what I want is a full outer join of t1 and t2 on workstation, and a cross-join of that with t3. I'm wondering if I can't find any examples of this online because it's not possible....
    Note: I'm stuck dealing with Oracle 8i
    Thanks!!

    Hi,
    The query I posted yesterday is a little more complicated than it needs to be.
    Since my_tab2.workstation is unique, there's no reason to do a separate sub-query like mt1; we can join my_tab1 to my_tab2 and get the SUM all in one sub-query.
    SELECT       foj.workstation
    ,       foj.sum_my_value
    ,       foj.wkstn_name
    ,       mt3.my_nbr1
    ,       mt3.my_nbr2
    FROM       (     -- Begin in-line view foj for full outer join
              SELECT        mt1.workstation
              ,        SUM (mt1.my_value)     AS sum_my_value
              ,        mt2.wkstn_name
              FROM        my_tab1   mt1
              ,        my_tab2   mt2
              WHERE        mt1.workstation     = mt2.workstation (+)
              GROUP BY   mt1.workstation
              ,        mt2.wkstn_name
                    UNION ALL
              SELECT      workstation
              ,      0      AS sum_my_value
              ,      wkstn_name
              FROM      my_tab2
              WHERE      workstation     NOT IN (     -- Begin NOT IN sub-query
                                               SELECT      workstation
                                       FROM      my_tab1
                                       WHERE      workstation     IS NOT NULL
                                     )     -- End NOT IN sub-query
           ) foj     -- End in-line view foj for full outer join
    ,       my_tab3  mt3
    ORDER BY  foj.wkstn_name
    ,       foj.workstation
    ,       mt3.my_nbr1
    ,       mt3.my_nbr2
    ;Thanks for posting the CREATE TABLE and INSERT statements, as well as the very clear desired results!
    user11033437 wrote:
    ... So, what I want is a full outer join of t1 and t2 on workstation, and a cross-join of that with t3. That it, exactly!
    The tricky part is how and when to get SUM (my_value). You might approach this by figuring out exactly what my_tab3 has to be cross-joined to; that is, exactly what should the result set of the full outer join between my_tab1 and my_tab2 look like. To do that, take your desired results, remove the columns that do not come from the full outer join, and remove the duplicate rows. You'll get:
    workstation     sum(my_value)     wkstn_name
    ABCD          30          WKSTN 1          
    A123          35          WKSTN 2          
    B456          0          WKSTN 3          
    ????          5          NULL          So the core of the problem is how to get these results from my_tab1 and my_tab2, which is done in sub-query foj above.
    I tried to use self-documenting names in my code. I hope you can understand it.
    I could spend hours explaining different parts of this query in more detail, but I'm sure I'd waste some of that time explaining things you already understand. If you want an explanation of somthing(s) specific, let me know.

  • Full Outer Join Help please

    Using : Oracle 11.2.0.1 on Windows XP
    create table tab40(bno varchar2(1),pno varchar2(7),weight number(3),lineno number(3));
    insert into tab40 values ('1','1115027',36,1);
    insert into tab40 values ('2','1115100',25,2);
    insert into tab40 values ('3','1115200',50,3);
    insert into tab40 values ('1','1112510',60,4);
    insert into tab40 values ('+','1112610',6,5);
    insert into tab40 values ('+','1112710',4,6);
    insert into tab40 values ('+','1110710',1,7);
    insert into tab40 values ('2','1117014',79,8);
    insert into tab40 values ('+','1117000',9,9);
    insert into tab40 values ('+','1117001',2,10);
    insert into tab40 values ('1','1317001',200,11);
    insert into tab40 values ('1','1697001',20,12);
    insert into tab40 values ('2','2997001',40,13);
    insert into tab40 values ('1','2996001',44,14);
    SQL> select * from tab40;
    B PNO         WEIGHT     LINENO
    1 1115027         36          1
    2 1115100         25          2
    3 1115200         50          3
    1 1112510         60          4
    + 1112610          6          5
    + 1112710          4          6
    + 1110710          1          7
    2 1117014         79          8
    + 1117000          9          9
    + 1117001          2         10
    1 1317001        200         11
    B PNO         WEIGHT     LINENO
    1 1697001         20         12
    2 2997001         40         13
    1 2996001         44         14
    14 rows selected.
    SQL>create table tab41(bno varchar2(1),pno varchar2(7),weight number(3),lineno number(3));
    insert into tab41 values ('1','1115027',36,1);
    insert into tab41 values ('2','1115100',25,2);
    insert into tab41 values ('3','1115200',50,3);
    insert into tab41 values ('1','1112510',60,4);
    insert into tab41 values ('+','1112610',6,5);
    insert into tab41 values ('+','1110710',1,6);
    insert into tab41 values ('2','1117014',79,7);
    insert into tab41 values ('+','1117000',9,8);
    insert into tab41 values ('1','1317001',200,9);
    insert into tab41 values ('1','1697001',20,10);
    insert into tab41 values ('2','2997001',40,11);
    insert into tab41 values ('1','2996001',44,12);
    insert into tab41 values ('+','1112710',4,13);
    insert into tab41 values ('+','3332710',8,14);
    SQL> select * from tab41;
    B PNO         WEIGHT     LINENO
    1 1115027         36          1
    2 1115100         25          2
    3 1115200         50          3
    1 1112510         60          4
    + 1112610          6          5
    + 1110710          1          6
    2 1117014         79          7
    + 1117000          9          8
    1 1317001        200          9
    1 1697001         20         10
    2 2997001         40         11
    B PNO         WEIGHT     LINENO
    1 2996001         44         12
    + 1112710          4         13
    + 3332710          8         14
    14 rows selected.
    SQL>Required Output :
    A       B          C          D        E       F          G          H
    1 1112510         60          4        1 2996001         44         12
    + 1112710          4          6        + 1112710          4         13
    2 1117014         79          8
    + 1117001          2         10
                                           1 2996001         44         12
                                           + 3332710          8         14Logic : The plus sign in Bno indicates that Packet No. was sent to customer with last non plus signed number packet (order by lineno) i.e. for example in tab40 there is line no. 6 whose master packet number is 1112510 (previous non plus signed rows's PNO). Now come to required output; which is showing that these plus signed packets (whose master PNO is that) are not as per tab40 vs tab41 something like full outer join between tab40 and tab41. Example :
    + 1112710 is associated with 1112510 in tab40, while in tab41 it is associated with 2996001; so it is difference.
    + 1117001 is associated with 1117014 in tab40, while it is not in tab41.
    vice versa;
    + 3332710 is associated with 2996001 in tab41, while it is not in tab40.
    I mean, if only plus marked row's PNO's mater packet number is not equal to master PNO(previous non plus marked BNO) in both the table, it should be part of the select query please. Generally this happens, when our packing department gets late delivery of prior master packet, so they just send the small packet with immediate available one (non plus) packet.
    Kindly let me; i am clear in my request or i should elaborate more. This may be more complex, because may be bad table/data design, but i need the output by select query please help me.
    Regards.
    Edited by: user12050217 on Jan 3, 2012 3:57 AM

    Yes, you have perfectly understood my question... just i added lineno > 1
    SELECT bno,
    pno,
    weight,
    lineno
    FROM ( SELECT tab40.*, lag (bno) OVER (ORDER BY pno) prev_bno
    FROM tab40
    ORDER BY pno)
    WHERE bno = '+' OR prev_bno = '+' and lineno > 1
    ORDER BY lineno
    and it worked, because there are no chances that plus marked row will be having lineno <=1
    B PNO         WEIGHT     LINENO
    1 1112510         60          4
    + 1112610          6          5
    + 1112710          4          6
    + 1110710          1          7
    2 1117014         79          8
    + 1117000          9          9
    + 1117001          2         10
    7 rows selected.

  • Again: two facts and one conformed dimension

    Dear all,
    I know this has been asked quite often but I haven't found a solution for my problem here. Believe me I have done a lot of searching across the net ..
    What I want to do is the following:
    I have two fact tables with a number of common dimensions. A report should show the two facts across these common dimensions.
    To keep it simple I start with only one common dimension.
    Here's what get's to the db from OBIEE:
    *SELECT Revenue."Date (YYYYMMDD)" saw_0, Sales."Day Day Code" saw_1, Revenue."TPV (Total Payment Volume in Millicent [€])" saw_2, Sales.DEBIT_AMOUNT saw_3 FROM "Company KPIs" ORDER BY saw_0, saw_1, saw_3*
    Note that *Revenue."Date (YYYYMMDD)"* and *Sales."Day Day Code"* are the same field from the common time dimension. I just put them in different presentation tables for the end users.
    TPV and DEBIT_AMOUNT are facts from the two different cubes.
    Everything fine, right?
    Now I look at the nqquery.log:
    RqList
    Dim Time.Day Day Code as c1 GB,
    Dim Time.Day Day Code as c2 GB,
    *Tpv:[DAggr(Cube Revenue.Tpv by [ Dim Time.Day Day Code, Dim Time.Day Id, CUBE_SALES.DEBIT_AMOUNT] )] as c3 GB,*
    CUBE_SALES.DEBIT_AMOUNT as c4 GB,
    Dim Time.Day Id as c5 GB
    OrderBy: c1 asc, c2 asc, c4 asc
    now the bold thing looks odd to me. Is he trying to aggregate one cube based on the other? Could be the problem, but where to influence this?
    And finally this translates into this query:
    WITH
    SAWITH0 AS (select distinct T4110.DEBIT_AMOUNT as c1,
    T281.DAY_DAY_CODE as c2,
    T281.DAY_ID as c3
    from
    DIM_TIME T281,
    CUBE_SALES T4110
    where ( T281.DIMENSION_KEY = T4110.DIM_TIME ) ),
    SAWITH1 AS (select distinct SAWITH0.c2 as c1,
    SAWITH0.c2 as c2,
    *cast(NULL as DOUBLE PRECISION ) as c3,*
    SAWITH0.c1 as c4,
    SAWITH0.c3 as c5
    from
    SAWITH0)
    select SAWITH1.c1 as c1,
    SAWITH1.c2 as c2,
    SAWITH1.c3 as c3,
    SAWITH1.c4 as c4
    from
    SAWITH1
    order by c1, c2, c4
    As you see, the tpy ist gone and a NULL appears. That's what I see in the report. TPV is always NULL.
    So where did I miss a configuration ???
    Thanks, Knut

    You only need to set the content levels on the measures themselves when you want non-conformed dimensions in the report, as your working with fully conformed dims just make sure your levels are set on the content tab for each Logical Table source in the Logical fact table. Leave the non-conformed dim hierarchies as blank.
    Remember - You should put a hierarchy on each logical dim , even if there is no real hierarchy, just have a total -> Detail.
    You should always always always set your content levels for logical table sources, both in Dimensions and Logical fact LTS's.
    If they are greyed out, make sure your not in read only, have checked the object out if on-line mode, failing that, perform the changes off-line then re-start your BI Server.

  • How can I join/Full outer join two different columns instead of union all?

    Hi,
    I have a scenario as the following:
    I am performing set operations using obiee 11g where I want to take values from two different criteria. Howwver, I dont want union to take place, instead i want join to take place to see all the columns in the output.
    For that, I tried changing the sql in advanced tab and tried to put full outer join instead of union all but its not allowing me to change.
    How can I achieve it? please help.
    Thanks.

    Hi,
    My problem is that I am unable to modify the sql in advanced tab. Probably due to some security reason,it's restricting me to change.
    Can you suggest me a way to change it?
    Thanks..

  • A dimension table outer join across two databases

    I have two databases of the same schema but may have different data that I would like to do comparisons on. For this discussion, each has two tables, Dimension and Fact. I created a common dimension which would show dimension data that exists on both databases. However, I want a common dimension which is a full outer join of the two Dimension tables that can be used to view data on the Fact tables on the two databases; this seems to be a little difference than a fact which may having missing value, isn't it? should this outer join occurs at the physical or logical? Can I even do it at physical if the data are from two different source? Any recommendation on what is the best way to do so? Thanks

    It depends on how you are defining your BM. Always, BM is for creating joins on folders within BM, in the sense that each folder can contain data from within multiple databases. So, create it in Physical layer and also create new joins for your defined facts dimensions in BM. But remember, cross database joins are not recommended. If both your schemas reside on 2 different oracle databases, you would be better off creating a single view (by creating a dblink between these 2 databases). So, create a single view and include that in the physical layer.
    Thanks,
    Venkat
    http://oraclebizint.wordpress.com

  • How can we make an outer join (+) between 2 Queries

    in the data model, i have 2 queries
    i.e
    Q_master and Q_detail
    i want to make a data link between
    these two queries and
    also make an outer join between these
    two queries(i.e. to display all the detail
    records, whether they have details or not)
    please reply is it possible ?
    if yes then how?
    plz write.
    [email protected]
    null

    Hello,
    Left outer join behavior is what you get by default with a link between two queries in Reports.
    If you want a full outer join behavior, you'll need to create a third query that selects the detail records that have no corresponding master, and also create an extra layout region to display them in as a default group left or group above won't pick up these extra records.
    If you want right outer join behavior, you'll need to put in a summary in the master query that counts the rows in the detail, and then put in a format trigger in the master repeating frame that suppresses printing when there are no detail records. And you'll also need the third query and layout section as in the full outer join case.
    Regards,
    The Oracle Reports Team --skw                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • Full Outer Join Help Needed

    Hi All,
    I am new to crystal and my sql.
    l have 2 command objects in that i have a common column pos_no.Now i need to apply Fullouterjoin between pos_no,but in crystal we don,t have that option.
    So i saw some threads that we need to apply leftouterjoin union rightouterjoin to get FOJ in db level ,i tried ,but i don't have much knowledge in my sql.So can any one please apply FOJ between Pos_no of these two queries.
    Please help me i strucked here
    1st Query:
    select
    MIN(till_close.start_transaction_id) AS start_trans_id,
    MAX(till_close.end_transaction_id) AS end_trans_id,
    pos_config.pos_no,
    pos_config.name AS pos_name,
    SUM(transaction_tender.amount) AS EodDeposit
    FROM
    till_close
    LEFT OUTER JOIN employee ON (till_close.employee_id = employee.employee_id)
    INNER JOIN pos_config ON (till_close.pos_config_id = pos_config.pos_config_id)
    INNER JOIN transaction_tender ON (till_close.end_transaction_id = transaction_tender.transaction_id)
    INNER JOIN media_type ON (transaction_tender.media_type_id = media_type.media_type_id)
    WHERE
      DATE_FORMAT(till_close.transaction_date,'%d/%m/%Y') = DATE_FORMAT(STR_TO_DATE(?,'%d/%m/%Y'),'%d/%m/%Y')
    AND transaction_tender.media_type_id NOT IN (10000)
    GROUP BY
    pos_config.pos_no
    ORDER BY
    pos_config.pos_no
    2nd Query:
    select
    pos_config.pos_no,
    pos_config.name AS pos_name,
    SUM(CASE WHEN transaction.transaction_type_id=7 AND ((SELECT COUNT(transaction_id) FROM transaction_tender WHERE transaction_id = transaction.transaction_id  AND media_type_id IN (SELECT media_type_id FROM media_type WHERE tender_type_id=12) AND amount < 0 )>0) THEN 0
      WHEN  transaction_tender.balance < 0
      THEN transaction_tender.amount
      ELSE (transaction_tender.amount - transaction_tender.balance)
      END) AS net
    FROM
    TRANSACTION
    INNER JOIN transaction_tender ON (transaction.transaction_id = transaction_tender.transaction_id)
    INNER JOIN media_type ON (transaction_tender.media_type_id = media_type.media_type_id)
    INNER JOIN pos_config ON (transaction.pos_config_id = pos_config.pos_config_id)
    WHERE
    transaction.transaction_date = DATE_FORMAT(STR_TO_DATE(?, '%d/%m/%Y'), '%Y-%m-%d')
    AND transaction.transaction_type_id IN (1,5,7)
    AND transaction.transaction_status_id = 3
    AND transaction.is_training_mode = 0
    GROUP BY
    pos_config.pos_no

    hi Divya,
    i would definitely take the advice from the folks here on a rewrite of your commands into one command.
    since you've got 2 commands that are bringing back different results you may wish to consider bringing back the results from the 2nd command via a sub-query.
    the general idea of the query is below, but you'll need to consult your online help for your database and or your dba for the correct syntax for your situation.
    notes:
    1) the subselect is in the bold font and is defined as a result set in the join...again, please consult your database help or the appropriated forum for your database as your syntax may vary
    2) the fields in the subquery are then referenced in the select clause using the TT alias assigned to the result set in the join
    3) the full outer join i guessed that you wanted on the two pos_no fields
    4) if you do try to do this method and are looking on your database forum, do a search on "subquery multiple columns"
    cheers,
    jamie
    select
    MIN(till_close.start_transaction_id) AS start_trans_id,
    MAX(till_close.end_transaction_id) AS end_trans_id,
    pos_config.pos_no AS PC_pos_no,
    pos_config.name AS pos_name AS PC_pos_name,
    SUM(transaction_tender.amount) AS EodDeposit,
    TT.pos_no AS TT_pos_no,
    TT.pos_name AS TT_pos_name,
    TT.net
    FROM
    till_close
    LEFT OUTER JOIN employee ON (till_close.employee_id = employee.employee_id)
    INNER JOIN pos_config ON (till_close.pos_config_id = pos_config.pos_config_id)
    INNER JOIN transaction_tender ON (till_close.end_transaction_id = transaction_tender.transaction_id)
    INNER JOIN media_type ON (transaction_tender.media_type_id = media_type.media_type_id)
    FULL OUTER JOIN
    (select
    pos_config.pos_no,
    pos_config.pos_name,
    SUM(CASE WHEN transaction.transaction_type_id=7 AND ((SELECT COUNT(transaction_id) FROM transaction_tender WHERE transaction_id = transaction.transaction_id  AND media_type_id IN (SELECT media_type_id FROM media_type WHERE tender_type_id=12) AND amount < 0 )>0) THEN 0
      WHEN  transaction_tender.balance < 0
      THEN transaction_tender.amount
      ELSE (transaction_tender.amount - transaction_tender.balance)
      END) AS net
    FROM
    TRANSACTION
    INNER JOIN transaction_tender ON (transaction.transaction_id = transaction_tender.transaction_id)
    INNER JOIN media_type ON (transaction_tender.media_type_id = media_type.media_type_id)
    INNER JOIN pos_config ON (transaction.pos_config_id = pos_config.pos_config_id)
    WHERE
    transaction.transaction_date = DATE_FORMAT(STR_TO_DATE(?, '%d/%m/%Y'), '%Y-%m-%d')
    AND transaction.transaction_type_id IN (1,5,7)
    AND transaction.transaction_status_id = 3
    AND transaction.is_training_mode = 0
    GROUP BY
    pos_config.pos_no) AS TT
    ON TT.pos_no =  pos_config.pos_no
    WHERE
      DATE_FORMAT(till_close.transaction_date,'%d/%m/%Y') = DATE_FORMAT(STR_TO_DATE(?,'%d/%m/%Y'),'%d/%m/%Y')
    AND transaction_tender.media_type_id NOT IN (10000)
    GROUP BY
    pos_config.pos_no
    ORDER BY
    pos_config.pos_no

  • Join between two tables in SAP ( actual sales vs budget sales)

    I have one table with  actual data sales in SAP .This table has a name   CE11000
    This table contain amounts about : customers ,Products, Quantity of Sales ,amount of sales ,month witch did the sales and the year.
    The other table from SAP has the budget sales . This table is CE21000
    This table contain the same fields : customers ,Products, Quantity of Sales ,amount of sales ,month witch did the sales and the year but all this for budget .
    In the budget table ( CE21000)there are no records for a particular make if it was not budgeted to make a sale.
    Sometimes i have the same problem with the actual data table (CE11000) ...I have not records witch can use to join the results for a report witch take the comparison between actual sales and budget sales.
    I would like to remind you that the report should have four "dimensions"
    a) year
    b) month
    c) customer
    d) type of product
    I try to use left outer join with a customer fields in two tables but i have  simultaneously the field with type of product .
    I want to see in one year (for example february of 2011)  for one customer the type of products (quantity and anmounts) witch buy (ACTUAL)  and that to  compare with the corresponding data if available
    Any help would appreciate
    thanks

    Haggar
    Your first query matches on two conditions BOTH being true. If there is a D and no matching E, you'll see the columns from D but none from E.
    Your second query takes all Emplyees, and lines up 2 (possibly different) rows from D against each
    E columns | D columns (match e.deptid=d.dept_id) | D columns (match ep_id=de_id)
    So you may have any mix of:
    E       | D1      | D2
    E       | nothing | D2
    nothing | D1      | D2
    E       | D1      | nothing
    E       | nothing | nothing
    nothing | D1      | nothing
    nothing | nothing | D2(NB I'm assuming FULL OUTER JOIN is commutative - ie the order is unimportant - but I may be wrong in which case the last row won't occur)
    You will get a different number of rows (as well as different columns) in each case.
    Try it!
    Regards Nigel

  • Query with FULL OUTER JOIN , help pleaseeeeeeeeeeee...

    Hi everyone,
    I'm trying to write a query for a report in Oracle SQL, but i just can't figure out how to do it.
    I'm using Oracle 10g release 1.0 database and i execute my queris in SQL* PLUS ( eventually i'm gonna use them in Oracle Report Builder ) .
    here's what i have:
    i have four tables that are used for our inventory application. lets call them INCOMMING , INCOMMING_ITEMS , OUTGOING , OUTGOING_ITEMS.
    as you may have guessed , INCOMMING_ITEMS is the detail table for INCOMMING ( joined by IID column) and also OUTGOING_ITEMS is the detail table for OUTGOING ( joined by OID column ).
    here is the structure of them :
    INCOMMING
    IID varchar2
    CDATE date
    INCOMMING_ITEM
    IID varchar2
    PART_NO number
    QTY number
    OUTGOING
    OID varchar2
    CDATE date
    OUTGOING_ITEM
    OID varchar2
    PART_NO number
    QTY number
    now , the query i want, should return part_no , cdate , sum of OUTGOING qty , sum of INCOMMING qty .
    the result of the query should be sth like this :
    part_no     cdate     O_qty     I_qty
    100     01/05/06     10     0
    100     01/05/07     20     60
    200     01/06/02     0     50
    300     01/06/02     30     40
    this means that for some dates and for some parts, i may not have INCOMMING or OUTGOING data, but if at least one of the 2 last columns has a non-zero data, i should show the row ( like the first and third rows of my example result), and if both have data for the same PART_NO and the same CDATE, both should be showed in the same row. ( like the second row in my example result)
    i tried so much and came up with several huge and also time consuming queries, but then i read abt FULL OUTER JOIN somewhere and tried using that. here is what i came up with :
    SELECT
    PART_NO , CDATE , sum(II.QTY) I_QTY , SUM (OI.QTY) O_QTY
    FROM
         (OUTGOING O INNER JOIN OUTGOING_ITEM OI USING ( OID ) )
    FULL OUTER JOIN
         (INCOMMING I INNER JOIN INCOMMING_ITEM II USING ( IID ) )
    ON ( I.CDATE = O.CDATE AND II.PART_NO = OI.PART_NO)
    WHERE
    I.CDATE = :PARAMETER1
    AND O.CDATE = :PARAMETER1
    GROUP BY
    PART_NO , CDATE
    this query is short and fast , but the results r not what i expected. i mean, although i have used FULL OUTER JOIN in the query , but the results i get r sth like this :
    part_no     cdate     O_qty     I_qty
    100     01/05/07     20     60
    300     01/06/02     30     40
    which means only the rows that has both values are returned.
    any change i make to this query would make the SQL* PLUS hang , like when i use the cartesian product of two large tables, so i guess my changes wheren't in the right direction.
    i think its possible to write this query using FULL OUTER JOIN syntax, but i just can't find it.
    Can anybody pleaseeeeeeeeeeeee help me?
    thanx in advance,
    Maryam.

    Note: I wrote this on the fly -- hope there is no syntax errors, otherwise forgive me -- but you get the idea..
    select
    fromUnionAll.cdate, fromUnionAll.part_no,
    sum(fromUnionAll.O_qty) O_qty,
    sum(fromUnionAll.I_qty) I_qty
    from
    select
    iinner.cdate, iinner.part_no, 0 O_qty, iinner.I_qty
    from
    select
    i.cdate, ii.part_no,
    /* added the case only for the extreme case when there is
    no record anywhere for the given CDATE in INCOMMING_item */
    sum( ( case when ii.qty is not null then ii.qty else 0 end) ) I_qty
    from
    incomming i,
    incomming_item ii
    where
    i.iid = ii.iid (+)
    group by i.cdate, ii.part_no
    ) iinner
    union all
    select
    oinner.cdate, oinner.part_no, oinner.O_qty, 0 I_qty
    from
    select
    o.cdate, oi.part_no,
    /* added the case only for the extreme case when there is
    no record anywhere for the given CDATE in OUTGOING_item */
    sum( ( case when oi.qty is not null then oi.qty else 0 end) ) O_qty
    from
    outgoing o,
    outgoing_item oi
    where
    o.oid = oi.oid (+)
    group by o.cdate, oi.part_no
    ) oinner
    ) fromUnionAll
    group by fromUnionAll.cdate, fromUnionAll.part_no;
    --Samson                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • Bridge Table between two fact tables

    Hello everybody,
    From what I have read on the BI Administration tool help and on this forum, bridge tables are used to define many-to-many relations between dimension sand fact tables. Is it possible to have a bridge table defining a many-to-many relation between two fact tables?
    Here is my senario:
    1. We have a fact table called fact_Orders describing orders for some products.
    2. We have a fact table called fact_Sales describing sales og these products.
    3. We have a table describing the transformation from order lines to sales lines which is a many-to-many relation, because it is possible to transform an order in more than two steps.
    I was thinking of connecting the two fact tables with a bridge table.
    If bridge tables are inappropriate for this case, what could be a better model for my senario?
    Thanks for your time.

    Hi,
    Well a conformed dimension is a bridge table between two facts, so not sure why you need anything else. If there is a one to many from D1 to F1 and a one to many from D1 to F2 then effectively there is a many to many join from F1 to F2 through the D1 dimension.
    Sounds to me like all you need is an order dimension table, rows in the orders fact table will join to this dimension and so will rows in the sales fact table. You can then do calculations like number of sales per order, total sales revenue per order, # of order items per order etc etc.
    Regards,
    Matt

Maybe you are looking for

  • I Pod classic not appearing in i tunes

    When I plug in my I pod Classic 80g the follwing error message occurs: There might be a problem with some of the files on this device or disk. This can happen if you remove the device or disk before all the files have been written to it. Scan & Fix (

  • IWeb 09 and phpBB3

    Hi there I am creating a website at the moment and want it to have a discussion forum using phpBB3. I was wondering if I am able to do this. The reason why I ask is that I want the forum to have the same look and feel to it as the main page. Regards

  • Today() generating error when used in an expression

    I am using today() as part of an expression to generate a conditional running total.  It is producing an error in the report output. =RunningValue( IIF( (not(IsNothing(Fields!PPAP_Sent_Date.Value)) and (Fields!PPAP_Sent_Date.Value <= Fields!PPAP_Requ

  • Country india version- vat

    Hi Experts, can you please  give me step by step procedure for configuring vat. regards, g.v.shivakkumar

  • Change fomat

    how do i change the file format to put dvds onto itunes? Thank You