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
Similar Messages
-
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 -
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.. -
How to get only matching rows in Full Outer Join
HI All,
I was recently asked this question.
How to fetch only matching data from two tables using Full Outer Join. Now, I understand that this is not the objective of using Full Joins but I was wondering whether this is possible or not.
Any help in this regard will be highly appreciated.Full outer join returns both matching and not matching rows, if you want only matching rows why you don't use INNER JOIN?
The following query does an INNER JOIN using a FULL JOIN which I think it doesn't make any sense.
SELECT *
FROM
A FULL OUTER JOIN B
ON A.ColumnName = B.ColumnName
WHERE
A.ColumnName IS NOT NULL
AND B.ColumnName IS NOT NULL
EntityLite: A Lightweight, Database First, Micro ORM -
How to merge 3 different query results using full outer join?
Hi all This is my my query for 2 results
with t1 as (
select trans.crAcc_id,trans.cr_amt,row_number() over (order by trans.head_id) rn from Acttrans trans,
Acttranhead head where trans.head_id in(select link_id from acttrans where head_id=12) and trans.crAcc_id!=0
and head.head_id=trans.head_id
t2 as (
select trans.drAcc_id,trans.dr_amt,head.[Vouc_No],head.[Vouc_Date] ,head.[Check_No],head.[Check_Date],head.[stat],row_number() over (order by trans.head_id) rn from Acttrans trans,
Acttranhead head where trans.head_id=12 and trans.drAcc_id!=0
and head.head_id=trans.head_id
select t1.crAcc_id, t1.cr_amt,t2.[Vouc_No],t2.[Vouc_Date] ,t2.[Check_No],t2.[Check_Date],t2.[stat],t2.drAcc_id,t2.dr_amt from t1
full outer join t2 on t1.rn = t2.rn
Query 3: SELECT [CrAcc_Id] FROM [KSSDATA].[dbo].[ActTrans] where head_id=12 and crAcc_id!=0
and i want to add Query3 result to the ABOVE RESULT but i am unable add third result using full outer join
Thanks
Balu D>>>but i am unable add third result using full outer join
Do you get the error or wrong result?
Best Regards,Uri Dimant SQL Server MVP,
http://sqlblog.com/blogs/uri_dimant/
MS SQL optimization: MS SQL Development and Optimization
MS SQL Consulting:
Large scale of database and data cleansing
Remote DBA Services:
Improves MS SQL Database Performance
SQL Server Integration Services:
Business Intelligence -
Full outer Join:ORA-01790
Hi All,
The issue may be silly, but we cant make it out:
DB : Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - ProdWe are running the below query with no issues:
select t1.text,t2.text text2,t1.line,decode(upper(t1.text),upper(t2.text),1,0) flg
from
(select text,row_number() over(order by line) line
from user_source
where name = 'COLL_MVIEW_REFRESH_PROC_LBK'
and replace(trim(text),chr(10)) is not null
) t1,
(select text ,row_number() over(order by line) line
from user_source
where name = 'COLL_MVIEW_REFRESH_PROC'
and trim(replace(text,chr(10))) is not null) t2
where t1.line = t2.lineBut when trying for an outer join it is giving error like
ORA-01790: expression must have same datatype as corresponding expressionOuter Join Query:
select t1.text,t2.text,t1.line,decode(upper(t1.text),upper(t2.text),1,0) flg
from
(select text,row_number() over(order by line) line
from user_source
where name = 'COLL_MVIEW_REFRESH_PROC_LBK'
and replace(trim(text),chr(10)) is not null
) t1 full outer join
(select text ,row_number() over(order by line) line
from user_source
where name = 'COLL_MVIEW_REFRESH_PROC'
and trim(replace(text,chr(10))) is not null) t2
on( t1.line = t2.line )Any idea what is wrong here?
Thanks,
JeneeshNot sure what is wrong with your version. It might have to do with row_number not working on an empty row (outer joined).
How about this alternative?
The approach is a bit different, but it uses only one access to the user_source view.
select s.lineNo, min(s.text1) text1, min(s.text2) text2, decode(upper(min(s.text1)), upper(min(s.text2)), 1, 0) flag
from
(select decode(u.name, 'COLL_MVIEW_REFRESH_PROC_LBK', u.text) text1
,decode(u.name, 'COLL_MVIEW_REFRESH_PROC'
, u.text) text2
,u.name,
row_number() over (partition by u.name order by u.line) lineNo
from user_source u
where u.name in ('COLL_MVIEW_REFRESH_PROC_LBK','COLL_MVIEW_REFRESH_PROC'
/* and u.TYPE = 'PROCEDURE' */
and replace(trim(u.text),chr(10)) is not null
) s
group by s.lineNo
order by s.lineNo;Edited by: Sven W. on Nov 18, 2008 5:24 PM -
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 -
Full outer join Bug or my misunderstanding?
CREATE GLOBAL TEMPORARY TABLE BP_ATTRIBUTE_CHARVAL_GTT
( "ATTRIBUTE_ID" NUMBER(10,0),
"PARTNER_ID" NUMBER(10,0),
"CHAR_VALUE" VARCHAR2(4000 BYTE),
"LAST_UPDATE_DATE" DATE,
"DISABLE_DATE" DATE
) ON COMMIT DEETE ROWS ;
CREATE TABLE BP_ATTRIBUTE_CHARVAL
( "ATTRIBUTE_ID" NUMBER(10,0),
"PARTNER_ID" NUMBER(10,0),
"CHAR_VALUE" VARCHAR2(4000 BYTE),
"LAST_UPDATE_DATE" DATE,
"DISABLE_DATE" DATE
REM INSERTING into BP_ATTRIBUTE_CHARVAL
Insert into BP_ATTRIBUTE_CHARVAL (ATTRIBUTE_ID,PARTNER_ID,CHAR_VALUE,LAST_UPDATE_DATE,DISABLE_DATE) values (888854,710326,'1',to_date('29-NOV-06','DD-MON-RR'),to_date('01-JAN-06','DD-MON-RR'));
Insert into BP_ATTRIBUTE_CHARVAL (ATTRIBUTE_ID,PARTNER_ID,CHAR_VALUE,LAST_UPDATE_DATE,DISABLE_DATE) values (591330,710326,'01',to_date('09-FEB-06','DD-MON-RR'),to_date('07-NOV-01','DD-MON-RR'));
Insert into BP_ATTRIBUTE_CHARVAL (ATTRIBUTE_ID,PARTNER_ID,CHAR_VALUE,LAST_UPDATE_DATE,DISABLE_DATE) values (591321,710326,'N',to_date('09-FEB-06','DD-MON-RR'),to_date('07-NOV-01','DD-MON-RR'));
Insert into BP_ATTRIBUTE_CHARVAL (ATTRIBUTE_ID,PARTNER_ID,CHAR_VALUE,LAST_UPDATE_DATE,DISABLE_DATE) values (591331,710326,'00',to_date('09-FEB-06','DD-MON-RR'),to_date('07-NOV-01','DD-MON-RR'));
Insert into BP_ATTRIBUTE_CHARVAL (ATTRIBUTE_ID,PARTNER_ID,CHAR_VALUE,LAST_UPDATE_DATE,DISABLE_DATE) values (591329,710326,'01',to_date('09-FEB-06','DD-MON-RR'),to_date('07-NOV-01','DD-MON-RR'));
Insert into BP_ATTRIBUTE_CHARVAL (ATTRIBUTE_ID,PARTNER_ID,CHAR_VALUE,LAST_UPDATE_DATE,DISABLE_DATE) values (591332,710326,'01',to_date('09-FEB-06','DD-MON-RR'),to_date('07-NOV-01','DD-MON-RR'));
Insert into BP_ATTRIBUTE_CHARVAL (ATTRIBUTE_ID,PARTNER_ID,CHAR_VALUE,LAST_UPDATE_DATE,DISABLE_DATE) values (591324,710326,'2',to_date('09-FEB-06','DD-MON-RR'),to_date('07-NOV-01','DD-MON-RR'));
Insert into BP_ATTRIBUTE_CHARVAL (ATTRIBUTE_ID,PARTNER_ID,CHAR_VALUE,LAST_UPDATE_DATE,DISABLE_DATE) values (591333,710326,'01',to_date('09-FEB-06','DD-MON-RR'),to_date('07-NOV-01','DD-MON-RR'));
Insert into BP_ATTRIBUTE_CHARVAL (ATTRIBUTE_ID,PARTNER_ID,CHAR_VALUE,LAST_UPDATE_DATE,DISABLE_DATE) values (591323,710326,'X1',to_date('09-FEB-06','DD-MON-RR'),to_date('07-NOV-01','DD-MON-RR'));
Insert into BP_ATTRIBUTE_CHARVAL (ATTRIBUTE_ID,PARTNER_ID,CHAR_VALUE,LAST_UPDATE_DATE,DISABLE_DATE) values (591334,710326,'BS',to_date('09-FEB-06','DD-MON-RR'),to_date('07-NOV-01','DD-MON-RR'));
REM INSERTING into BP_ATTRIBUTE_CHARVAL_GTT
Insert into BP_ATTRIBUTE_CHARVAL_GTT(ATTRIBUTE_ID,PARTNER_ID,CHAR_VALUE,LAST_UPDATE_DATE,DISABLE_DATE) values (591330,707408,'01',to_date('29-MAR-06','DD-MON-RR'),to_date('07-NOV-01','DD-MON-RR'));
Insert into BP_ATTRIBUTE_CHARVAL_GTT(ATTRIBUTE_ID,PARTNER_ID,CHAR_VALUE,LAST_UPDATE_DATE,DISABLE_DATE) values (591321,707408,'N',to_date('23-JAN-06','DD-MON-RR'),to_date('07-NOV-01','DD-MON-RR'));
Insert into BP_ATTRIBUTE_CHARVAL_GTT(ATTRIBUTE_ID,PARTNER_ID,CHAR_VALUE,LAST_UPDATE_DATE,DISABLE_DATE) values (591331,707408,'00',to_date('23-JAN-06','DD-MON-RR'),to_date('07-NOV-01','DD-MON-RR'));
Insert into BP_ATTRIBUTE_CHARVAL_GTT(ATTRIBUTE_ID,PARTNER_ID,CHAR_VALUE,LAST_UPDATE_DATE,DISABLE_DATE) values (591329,707408,'01',to_date('23-JAN-06','DD-MON-RR'),to_date('07-NOV-01','DD-MON-RR'));
Insert into BP_ATTRIBUTE_CHARVAL_GTT(ATTRIBUTE_ID,PARTNER_ID,CHAR_VALUE,LAST_UPDATE_DATE,DISABLE_DATE) values (591332,707408,'00',to_date('29-MAR-06','DD-MON-RR'),to_date('07-NOV-01','DD-MON-RR'));
Insert into BP_ATTRIBUTE_CHARVAL_GTT(ATTRIBUTE_ID,PARTNER_ID,CHAR_VALUE,LAST_UPDATE_DATE,DISABLE_DATE) values (591324,707408,'2',to_date('29-MAR-06','DD-MON-RR'),to_date('07-NOV-01','DD-MON-RR'));
Insert into BP_ATTRIBUTE_CHARVAL_GTT(ATTRIBUTE_ID,PARTNER_ID,CHAR_VALUE,LAST_UPDATE_DATE,DISABLE_DATE) values (591333,707408,'01',to_date('23-JAN-06','DD-MON-RR'),to_date('07-NOV-01','DD-MON-RR'));
Insert into BP_ATTRIBUTE_CHARVAL_GTT(ATTRIBUTE_ID,PARTNER_ID,CHAR_VALUE,LAST_UPDATE_DATE,DISABLE_DATE) values (591323,707408,'X1',to_date('23-JAN-06','DD-MON-RR'),to_date('07-NOV-01','DD-MON-RR'));
Insert into BP_ATTRIBUTE_CHARVAL_GTT(ATTRIBUTE_ID,PARTNER_ID,CHAR_VALUE,LAST_UPDATE_DATE,DISABLE_DATE) values (591334,707408,'BS',to_date('23-JAN-06','DD-MON-RR'),to_date('07-NOV-01','DD-MON-RR'));
Insert into BP_ATTRIBUTE_CHARVAL_GTT(ATTRIBUTE_ID,PARTNER_ID,CHAR_VALUE,LAST_UPDATE_DATE,DISABLE_DATE) values (876570,707408,'01',to_date('29-MAR-06','DD-MON-RR'),to_date('07-NOV-01','DD-MON-RR'));
Insert into BP_ATTRIBUTE_CHARVAL_GTT (ATTRIBUTE_ID,PARTNER_ID,CHAR_VALUE,LAST_UPDATE_DATE,DISABLE_DATE) values (876568,707408,'1234560003264801',to_date('29-MAR-06','DD-MON-RR'),to_date('07-NOV-01','DD-MON-RR'));
Insert into BP_ATTRIBUTE_CHARVAL_GTT(ATTRIBUTE_ID,PARTNER_ID,CHAR_VALUE,LAST_UPDATE_DATE,DISABLE_DATE) values (876569,707408,'f3a1d996-720e-4e0a-989c-6d4f3e8e629a',to_date('29-MAR-06','DD-MON-RR'),to_date('07-NOV-01','DD-MON-RR'));
Insert into BP_ATTRIBUTE_CHARVAL_GTT(ATTRIBUTE_ID,PARTNER_ID,CHAR_VALUE,LAST_UPDATE_DATE,DISABLE_DATE) values (874948,707408,'20060318000000',to_date('29-MAR-06','DD-MON-RR'),to_date('07-NOV-01','DD-MON-RR'));
select 707408,
decode(g.attribute_id,NULL,c.attribute_id,g.attribute_id) attribute_id,
case
when c.last_update_date is null and g.last_update_date is not null
then
g.char_value
when g.last_update_date is null and c.last_update_date is not null
then
c.char_value
when g.last_update_date >= c.last_update_date
then
g.char_value
else
c.char_value
end char_value,
decode(g.last_update_date,c.last_update_date,g.last_update_date,c.last_update_date) last_update_date,
decode(g.disable_date,c.disable_date,g.disable_date,c.disable_date) disable_date
from bp_attribute_charval_gtt g
full outer join
bp_attribute_charval c
on c.attribute_id = g.attribute_id
where c.partner_id=710326;Hi Guys
When I run the above query I get a problem.
I am expecting to see is a merge of all the attribute_id's and their values.
The query does not appear to be merging the data as intended.
My understanding of the full outer join is that its a combination of left and outer joins,
so the above query is intended to return with the total number of unique attributes
and their appropriate values
a) I have a bug in the Sql
b) This is an oracle bug
c) My understanding is incorrect
Please Help
Message was edited by:
Keith Jamieson (fixed insert statements for gtt )How do you expect a full outer join operation when you have given --
where c.partner_id=710326;According to your supplied data - i don't think your query can perform that full outer join operation because of that filtration. Just remove that last condition and checked it. You will get your desired result - hopefully.
"It's like you want to view the things by closing down your both eyes". Do you think it will pay?
Regards.
Satyaki De. -
Repalcing UNIOn with full outer Join
I have a query wihch looks like ,
select colA,colB ,colC, coldD from A,B,C,D
where (some join conditions)
union
select colA,colB ,colC, NULL from A,B,C
where (some join conditions)
This query is posing us serious performance issues and we want to tune the query.
SO to remove the UNION operator we want to use FULL JOIN.
Can you please let us know how to frame the full outer join in the above query,so that the result set intact.
Thanks MuchHere goes my first query that uses UNION :
SELECT from_it.seq_routing,
from_it.milestone_routing_dt,
from_it.milestone_type_desc,
to_it.seq_routing,
to_it.milestone_routing_dt,
to_it.milestone_type_desc,
to_it.delay_flag,
to_it.acceptable_delay_flag,
TAB_A.calendar_minutes, TAB_A.business_minutes,
TAB_A.due_date, TAB_A.late_minutes,
TAB_A.delay_concat_comments,TAB_C.TAB_C_key,
TAB_C.pcd,TAB_C.ssn,
mmp.MEASURE_NAME,
api.METRICS_PARAMETER_KEY,
api.METRICS_PARAMETER_PRODUCT_KEY,
crt.JUSTIFICATION_CD,
crt.JUSTIFICATION_DESC,
crt.ROUTING_USER_SITE_DESC
FROM TAB_A, TAB_B from_it, TAB_B to_it,
TAB_C, TAB_E,TAB_D mmp,TAB_F api, TAB_G crt
WHERE from_it.TAB_B_key =
TAB_A.from_TAB_B_key
AND to_it.TAB_B_key =
TAB_A.to_TAB_B_key
ANDTAB_C.TAB_C_key = from_it.TAB_C_key
andTAB_C.TAB_C_key = to_it.TAB_C_key
and TAB_E.pck =crt.pck
and to_it.SEQ_ROUTING =crt.SEQ_ROUTING
and TAB_E.pcd =TAB_C.pcd
and TAB_E.ssn =TAB_C.ssn
andTAB_C.END_DT = TO_DATE('12/31/9999', 'MM/DD/YYYY')
and TAB_A.METRICS_MEASURE_KEY =mmp.METRICS_MEASURE_KEY
andapi.END_DT = TO_DATE('12/31/9999', 'MM/DD/YYYY')
andTAB_C.TAB_C_key =api.TAB_C_KEY
andapi.PARAMETER_TYPE = 'IN'
and TAB_A.end_dt = TO_DATE('12/31/9999', 'MM/DD/YYYY')
and CRT.end_dt = TO_DATE('12/31/9999', 'MM/DD/YYYY')
UNION
SELECT from_it.seq_routing,
from_it.milestone_routing_dt,
from_it.milestone_type_desc,
to_it.seq_routing,
to_it.milestone_routing_dt,
to_it.milestone_type_desc,
to_it.delay_flag,
to_it.acceptable_delay_flag,
TAB_A.calendar_minutes, TAB_A.business_minutes,
TAB_A.due_date, TAB_A.late_minutes,
TAB_A.delay_concat_comments,TAB_C.TAB_C_key,
TAB_C.pcd,TAB_C.ssn,
mmp.MEASURE_NAME,
api.METRICS_PARAMETER_KEY,
api.METRICS_PARAMETER_PRODUCT_KEY,
NULL, NULL, NULL
FROM TAB_A, TAB_B from_it, TAB_B to_it,
TAB_C, TAB_E,TAB_D mmp,TAB_F api
WHERE from_it.TAB_B_key =
TAB_A.from_TAB_B_key
AND to_it.TAB_B_key =
TAB_A.to_TAB_B_key
ANDTAB_C.TAB_C_key = from_it.TAB_C_key
andTAB_C.TAB_C_key = to_it.TAB_C_key
and TAB_E.pcd =TAB_C.pcd
and TAB_E.ssn =TAB_C.ssn
andTAB_C.END_DT = TO_DATE('12/31/9999', 'MM/DD/YYYY')
and TAB_A.METRICS_MEASURE_KEY =mmp.METRICS_MEASURE_KEY
andapi.END_DT = TO_DATE('12/31/9999', 'MM/DD/YYYY')
andTAB_C.TAB_C_key =api.TAB_C_KEY
andapi.PARAMETER_TYPE = 'IN'
and to_it.SEQ_ROUTING is null
and TAB_A.end_dt = TO_DATE('12/31/9999', 'MM/DD/YYYY')
And the one with OUTER JOIN used :
SELECT from_it.seq_routing,
from_it.milestone_routing_dt,
from_it.milestone_type_desc,
to_it.seq_routing,
to_it.milestone_routing_dt,
to_it.milestone_type_desc,
to_it.delay_flag,
to_it.acceptable_delay_flag,
TAB_A.calendar_minutes, TAB_A.business_minutes,
TAB_A.due_date, TAB_A.late_minutes,
TAB_A.delay_concat_comments,TAB_C.TAB_C_key,
TAB_C.pcd,TAB_C.ssn,
mmp.MEASURE_NAME,
api.METRICS_PARAMETER_KEY,
api.METRICS_PARAMETER_PRODUCT_KEY,
crt.JUSTIFICATION_CD,
crt.JUSTIFICATION_DESC,
crt.ROUTING_USER_SITE_DESC
FROM TAB_A JOIN
TAB_B from_it
on from_it.TAB_B_key =
TAB_A.from_TAB_B_key
and TAB_A.end_dt = TO_DATE('12/31/9999', 'MM/DD/YYYY')
JOIN
TAB_B to_it
ON to_it.TAB_B_key =
TAB_A.to_TAB_B_key
JOINTAB_C
ONTAB_C.TAB_C_key = from_it.TAB_C_key
ANDTAB_C.TAB_C_key = to_it.TAB_C_key
andTAB_C.END_DT = TO_DATE('12/31/9999', 'MM/DD/YYYY')
JOINTAB_D mmp
ON TAB_A.METRICS_MEASURE_KEY =mmp.METRICS_MEASURE_KEY
JOIN TAB_E
ON TAB_E.pcd =TAB_C.pcd
and TAB_E.ssn =TAB_C.ssn
-- and TAB_E.ssn = 'PFEARG'
JOINTAB_F api
ON TAB_C.TAB_C_key =api.TAB_C_KEY
andapi.PARAMETER_TYPE = 'IN'
andapi.END_DT = TO_DATE('12/31/9999', 'MM/DD/YYYY')
LEFT -
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. -
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
Surya872073 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 -
When i want to use FULL OUTER JOIN feature in CR 10, i always found it disable. How i can enable, i am in great need.........
I believe you have to write your own command object in order to use it per this kbase:
http://technicalsupport.businessobjects.com/KanisaSupportSite/search.do?cmd=displayKC&docType=kc&externalId=c2012108&sliceId=&dialogID=20756004&stateId=1 0 20754390
I am moving this to the Crystal Reports forum. -
Unable to collapse rows after full outer joining several tables
All -
I often do a "full outer join" on numerous tables when I want to report all of the
contents of all of the tables in one relatively easy to inspect set of output. However,
now that my "leading" table is missing certain values, my output is definitely not
what I want.
Here's a test case:
drop table test11;
create table test11 (x number);
insert into test11 values (1);
insert into test11 values (3);
drop table test12;
create table test12 (x number);
insert into test12 values (2);
insert into test12 values (3);
drop table test13;
create table test13 (x number);
insert into test13 values (1);
insert into test13 values (2);
drop table test14;
create table test14 (x number);
insert into test14 values (2);
commit;
select test11.x t11,
test12.x t12,
test13.x t13,
test14.x t14
from (((test11 full outer join test12 on test11.x = test12.x)
full outer join test13 on test11.x = test13.x)
full outer join test14 on test11.x = test14.x);
And here is the output:
T11 T12 T13 T14
1 1
3 3
2
2
2
5 rows selected.
Forgive me if this doesn't appear with a fixed-width font. I
don't know how to format these postings.
See rows 3, 4, and 5? My desire is to jam those
together so that my output is this instead:
T11 T12 T13 T14
1 1
3 3
2 2 2
3 rows selected.
Do you have any idea how to do this? Of course, I'll need to
apply the solution to the general case so that all
test cases similar to this are fixed!
Thanks very much for your time!
Tom G.For anyone who's interested -
Here is the solution I was able to put together on my own:
select max(t11) t11, max(t12) t12, max(t13) t13, max(t14) t14 from
select coalesce(test11.x, test12.x, test13.x, test14.x) ct,
test11.x t11,
test12.x t12,
test13.x t13,
test14.x t14
from (((test11 full outer join test12 on test11.x = test12.x)
full outer join test13 on test11.x = test13.x)
full outer join test14 on test11.x = test14.x))
group by ct;And the output:
T11 T12 T13 T14
2 2 2
1 1
3 3
3 rows selected.Bye,
Tom G. -
Using FILTER after a FULL OUTER JOIN problem in OWB
Hi,
I’m using OWB 11.2.
In an OWB mapping I need to detect every changes (Insert, Update, Delete) made to the data of a table. In order to find these changes I need to use “FULL OUTER JOIN” and a “FILTER” to join current table to previous table.
My desired generated query should be like this:
Select *
From tab1 FULL OUTER JOIN tab2 on JOIN_CONDITION
WHERE FILTER_CONDITION
The problem is that when OWB generates the code, the query will be like this:
Select *
From tab1 FULL OUTER JOIN tab2 on JOIN_CONDITION AND FILTER_CONDITION
As you know these 2 queries are not the same at all!
I don’t know how to make OWB generate my desired SQL. Please help me…Works ok on 11.2.0.3
Are you using "( + )" for join condition in joiner? Or, are you using "Join input role" parameter to define full outer join condition? Are you using oracle or ANSI syntax? -
Hi, all
Is it possible to make FULL OUTER JOIN in BI InfoSet?
If no, another question - is it possible to switch base InfoProvider? I have an InfoSet with InfoCube1 and DSO1 which I can outer join. I want to outer join InfoCube1 , not DSO1 that's why I need to switch them in the InfoSet.Hi,
In BI 7.0 Infoset has given chance to include an Info cube also,maximum you can include 2 info Cubes only in a infoset.
check the below link which helps you in understanding of the join conditions so that you can apply to your scenario.
http://help.sap.com/saphelp_nw2004s/helpdata/en/f1/713c3b35703079e10000000a114084/content.htm
http://help.sap.com/saphelp_nw2004s/helpdata/en/67/7e4b3eaf72561ee10000000a114084/content.htm
Regards,
Praveena.
Maybe you are looking for
-
Is it possible to Configure VPC Between N5010 and 6513
Hello Gents, Please let me know if we can configure VPC Between N5010 and 6513(coreswitch). IF Yes, Does it have any loops or abnormal traiffc behaviour ? Please refer the attached mail for current network diagram 1) I would like to establish VPC Be
-
Need to clear last selected prompt values while refreshing webi report
While using ALL within cascading prompts its still showing the last prompt values selected in infoview and not while editing and trying to run webi reports. Is there any way to clear this? I have implemented following options to resolve but did not
-
Question regarding GO URL link with &Action=Navigate in OBIEE 11g
Hello All, Actually I am working with the GO URL Links in OBIEE 11g.When I am trying to use the link as &Action=Navigate&p0=3&p1=bet&p2="Time%20Periods".Date&p3=2+ '01/01/2011'+'01/31/2011' The data is not getting filtered.It is giving me all the dat
-
How do I make my hp 4280 printer discoverable for my Mac Notebook to find?
I am a new Mac user and I have a Mac Pro desktop and a Mac notebook and would like to make my HP 4280 a wireless printer. how do I do that? thanks bob
-
Dear All, We have purchased 10 Diff materials with with 4% VAT Cr & At the end of month my client will decide to avail the 80% VAT for only 4 materials and 20% wants to add into the material cost. It will be decided on the base of consumption of mate