Outer Joins with multiple conditions - alternatives to UNION?
It is my understanding that Oracle 8i does not directly support mutiple conditions for outer joins. For instance, I'm looking for PEOPLE who may, or may not, be on MEDICATIONS.
All MEDICATIONS are listed with DRUGNAME and DRUGID. There thousand of different drugs. I'm only looking for PEOPLE on either one or two of them (to make it simple) or no drug at all (ignoring all other DRUGS they're on..) IF they are on the DRUG, it's gerts printed.
I'd ideally do a LEFT OUTER JOIN to do this with multiple conditions:
SELECT DISTINCT
PERSON.NAME,
MEDICATION.DRUGNAME,
MEDICATION.DRUGID
FROM
PERSON,
MEDICATION
WHERE
PERSON.ID = MEDICATION.ID (+) AND
(MEDICATION.DRUGID (+) = 632 OR
MEDICATION.DRUGID (+) = 956)
This, of course, is not valid, at least in 8i...
So I've taken the UNION approach:
SELECT DISTINCT
PERSON.NAME,
MEDICATION.DRUGNAME,
MEDICATION.DRUGID
FROM
PERSON,
MEDICATION
WHERE
PERSON.ID = MEDICATION.ID (+) AND
MEDICATION.DRUGID (+) = 632
UNION
SELECT DISTINCT
PERSON.NAME,
MEDICATION.DRUGNAME,
MEDICATION.DRUGID
FROM
PERSON,
MEDICATION
WHERE
PERSON.ID = MEDICATION.ID (+) AND
MEDICATION.DRUGID (+) = 956
This of course, does work, but as I've added more drugs this becomes quite unwieldly and not really sure what this does to performance. (There are also several more joins to other tables, not relevent here.)
In addition, if I import this into Crystal Reports 8.5 (as opposed to the Crystal Query Designer), it refuses to recognize the UNION.
-- Any suggestions for alternative syntax ???
-- Has this been addressed in 9i ???
Thanks,
Will
You could try
select Distinct Person.Name, Med.DrugName, Med.DrugId
from Person,
(select ID, DrugName, DrugId from Medication
where DrugId in (632, 956) ) Med
where Person.ID = Med.ID(+)
SELECT DISTINCT
PERSON.NAME,
MEDICATION.DRUGNAME,
MEDICATION.DRUGID
FROM
PERSON,
MEDICATION
WHERE
PERSON.ID = MEDICATION.ID (+) AND
(MEDICATION.DRUGID (+) = 632 OR
MEDICATION.DRUGID (+) = 956)
This, of course, is not valid, at least in 8i...
So I've taken the UNION approach:
SELECT DISTINCT
PERSON.NAME,
MEDICATION.DRUGNAME,
MEDICATION.DRUGID
FROM
PERSON,
MEDICATION
WHERE
PERSON.ID = MEDICATION.ID (+) AND
MEDICATION.DRUGID (+) = 632
UNION
SELECT DISTINCT
PERSON.NAME,
MEDICATION.DRUGNAME,
MEDICATION.DRUGID
FROM
PERSON,
MEDICATION
WHERE
PERSON.ID = MEDICATION.ID (+) AND
MEDICATION.DRUGID (+) = 956
This of course, does work, but as I've added more drugs this becomes quite unwieldly and not really sure what this does to performance. (There are also several more joins to other tables, not relevent here.)
In addition, if I import this into Crystal Reports 8.5 (as opposed to the Crystal Query Designer), it refuses to recognize the UNION.
-- Any suggestions for alternative syntax ???
-- Has this been addressed in 9i ???
Thanks,
Will
Similar Messages
-
Left outer join with multiple conditions
Is it possible to add to a left outer join (= anyOfAllowingNone) more than the primary condition (in SQL this would be added per "and").
Background: The execution plan of the produced SQL shows large results on which the final filter is applied although I have conditions that would decrease this last result set much earlier...There is no easy way to do this in TopLink expressions, other than including the join in the regular where clause as you have done. Does it make a big impact in the performance of your query?
<p>
You could use custom SQL for the query.
<p>
Or you could potentially define a OneToOneQueryKey in your TopLink descriptor that includes the additional join criteria and call anyOfAllowingNone using this query key.
<p>
<p>---
<p>James Sutherland -
Outer join with Filter condition
Hi there,
I need some help with Data Services. I am creating an outer join between two tables and one of them has filter condition but it creates and outerjoin and apply the filter condition to the whole result set.
SELECT "IWFMR13T_VEH_NTK_TMP1"."ACTY_DT" , "IWFMR13T_VEH_NTK_TMP1"."VEH_CL" , "IWFMR13T_VEH_NTK_TMP1"."VEH_NO" , "IWFMR13T_VEH_NTK_TMP1"."SRVC_NO" , "IWFMR13T_VEH_NTK_TMP1"."SRVC_STRT_DT" , "IWFMR13T_VEH_NTK_TMP1"."FR_SRVC_SEQ_NO" , "IWFMR13T_VEH_NTK_TMP1"."TO_SRVC_SEQ_NO" , "IWFMR13T_VEH_NTK_TMP1"."FR_ACTY_TS" , "IWFMR13T_VEH_NTK_TMP1"."TO_ACTY_TS" , "IWFMR13T_VEH_NTK_TMP1"."MINS_ON_TRN" , "IWFMR13T_VEH_NTK_TMP1"."VEH_STA_CD" , "IWFMR13T_VEH_NTK_TMP1"."MAJ_VEH_CD" , "IWFMR13T_VEH_NTK_TMP1"."VEH_DIST_KM" , "IWFMR13T_VEH_NTK_TMP1"."VEH_NET_TN" , "IWFMR13T_VEH_NTK_TMP1"."VEH_GROS_TN" , "IWFMR13T_VEH_NTK_TMP1"."VEH_NTK" , "IWFMR13T_VEH_NTK_TMP1"."VEH_GTK" , "IWFMR13T_VEH_NTK_TMP1"."HLNG_LOCO_MPU" , "IWFMR13T_VEH_NTK_TMP1"."09_HLNG_LOCO_FL" , "IWFMR13T_VEH_NTK_TMP1"."LOCO_MPU" , "IWFMR11T_SGMT_LCNT"."SUM_LOCO_MPU" , "IWFMR13T_VEH_NTK_TMP1"."SRVC_BUS_GRP_CD" , "IWFMR13T_VEH_NTK_TMP1"."SRVC_COAL_MRKR_CD"
FROM "DBO"."IWFMR13T_VEH_NTK_TMP1" "IWFMR13T_VEH_NTK_TMP1"
LEFT OUTER JOIN "DBO"."IWFMR11T_SGMT_LCNT" "IWFMR11T_SGMT_LCNT"
ON ( "IWFMR11T_SGMT_LCNT"."SRVC_NO" = "IWFMR13T_VEH_NTK_TMP1"."SRVC_NO" ) AND( "IWFMR11T_SGMT_LCNT"."SRVC_STRT_DT" = "IWFMR13T_VEH_NTK_TMP1"."SRVC_STRT_DT" ) AND( "IWFMR11T_SGMT_LCNT"."FR_SRVC_SEQ_NO" = "IWFMR13T_VEH_NTK_TMP1"."FR_SRVC_SEQ_NO" ) AND( "IWFMR11T_SGMT_LCNT"."TO_SRVC_SEQ_NO" = "IWFMR13T_VEH_NTK_TMP1"."TO_SRVC_SEQ_NO" )
WHERE ( "IWFMR13T_VEH_NTK_TMP1"."09_HLNG_LOCO_FL" = 'Y')
While, what I need is as under
SELECT "IWFMR13T_VEH_NTK_TMP1"."ACTY_DT" , "IWFMR13T_VEH_NTK_TMP1"."VEH_CL" , "IWFMR13T_VEH_NTK_TMP1"."VEH_NO" , "IWFMR13T_VEH_NTK_TMP1"."SRVC_NO" , "IWFMR13T_VEH_NTK_TMP1"."SRVC_STRT_DT" , "IWFMR13T_VEH_NTK_TMP1"."FR_SRVC_SEQ_NO" , "IWFMR13T_VEH_NTK_TMP1"."TO_SRVC_SEQ_NO" , "IWFMR13T_VEH_NTK_TMP1"."FR_ACTY_TS" , "IWFMR13T_VEH_NTK_TMP1"."TO_ACTY_TS" , "IWFMR13T_VEH_NTK_TMP1"."MINS_ON_TRN" , "IWFMR13T_VEH_NTK_TMP1"."VEH_STA_CD" , "IWFMR13T_VEH_NTK_TMP1"."MAJ_VEH_CD" , "IWFMR13T_VEH_NTK_TMP1"."VEH_DIST_KM" , "IWFMR13T_VEH_NTK_TMP1"."VEH_NET_TN" , "IWFMR13T_VEH_NTK_TMP1"."VEH_GROS_TN" , "IWFMR13T_VEH_NTK_TMP1"."VEH_NTK" , "IWFMR13T_VEH_NTK_TMP1"."VEH_GTK" , "IWFMR13T_VEH_NTK_TMP1"."HLNG_LOCO_MPU" , "IWFMR13T_VEH_NTK_TMP1"."09_HLNG_LOCO_FL" , "IWFMR13T_VEH_NTK_TMP1"."LOCO_MPU" , "IWFMR11T_SGMT_LCNT"."SUM_LOCO_MPU" , "IWFMR13T_VEH_NTK_TMP1"."SRVC_BUS_GRP_CD" , "IWFMR13T_VEH_NTK_TMP1"."SRVC_COAL_MRKR_CD"
FROM "DBO"."IWFMR13T_VEH_NTK_TMP1" "IWFMR13T_VEH_NTK_TMP1"
LEFT OUTER JOIN "DBO"."IWFMR11T_SGMT_LCNT" "IWFMR11T_SGMT_LCNT"
ON ( "IWFMR11T_SGMT_LCNT"."SRVC_NO" = "IWFMR13T_VEH_NTK_TMP1"."SRVC_NO" ) AND( "IWFMR11T_SGMT_LCNT"."SRVC_STRT_DT" = "IWFMR13T_VEH_NTK_TMP1"."SRVC_STRT_DT" ) AND( "IWFMR11T_SGMT_LCNT"."FR_SRVC_SEQ_NO" = "IWFMR13T_VEH_NTK_TMP1"."FR_SRVC_SEQ_NO" ) AND( "IWFMR11T_SGMT_LCNT"."TO_SRVC_SEQ_NO" = "IWFMR13T_VEH_NTK_TMP1"."TO_SRVC_SEQ_NO" ) AND ( "IWFMR13T_VEH_NTK_TMP1"."09_HLNG_LOCO_FL" = 'Y')
Please let me know, how to fix this issue. If you have come across such issue before. If need be I can send you the ATL file for this data flow.
BTW, I am using Data Services XI 3.2 (12.2.0.0) and the database is SQL 2005, both on Windows Platform.
Thanks & regards,
Doshi BhaveshHi,
Use two query transforms;
First will only connect to IWFMR13T_VEH_NTK_TMP1 and use it to apply filter "IWFMR13T_VEH_NTK_TMP1"."09_HLNG_LOCO_FL" = 'Y'
In second query transform perform outer join on IWFMR11T_SGMT_LCNT and output of first query.
This should give required result.
If you are using single query transform join will be performed at DB level and if you use custom sql in query transform it will not have increased load on DB. I will recommend to use custom sql to get good performance.
Sachin -
Left outer join using multiple table
Hi,
I am trying to use left outer join with multiple tables , the join condition will be based on PERNR and BEGDA & ENDA for each infotype in selection screen.
select pa00~pernr pa00~begda pa00~endda pa00~massn pa00~massg pa00~stat2 pa00~aedtm pa00~uname
pa01~begda pa01~endda pa01~bukrs pa01~persg pa01~persk pa01~mstbr pa01~ename pa01~aedtm pa01~uname
pa02~begda pa02~endda pa02~nachn pa02~vorna pa02~midnm pa02~aedtm pa02~uname
pa016~begda pa016~endda pa016~cttyp pa016~aedtm pa016~uname
into CORRESPONDING FIELDS OF TABLE i_pall
from ( PA0000 as pa00 left OUTER JOIN pa0001 as pa01 on pa00~pernr = pa01~pernr )
left OUTER JOIN pa0002 as pa02 on pa00~pernr eq pa02~pernr )
left OUTER JOIN pa0016 as pa016 on pa00~pernr eq pa016~pernr )
where pa00~pernr in S_pernr
AND pa00~begda in s_bg0000
and pa00~endda in s_nd0000.
but this fails to fetch the value of begda enda from each pa0000,pa0001,pa0002,pa0016.
Please help!
MonirulWhy don't you use the standard logical database PNPCE and then Provide statement?
-
I have a very complicated query to construct that requires the use of 'AND', 'OR', and Outer Joins. Oracle's 9i documentation says you can't use an outer join with an 'OR'.
Can you suggest how I may return the correct records under the following conditions. There are 3 tables to join. Table A, Table B, and Table C. Tables A & B join with an = to common fields. The problem is with Table C.
The way the application was designed, it has to track a parent and child relationship. As such, the field to relate may exist in 1 of 2 fields. Let's see if I can draw it out for you.
Table A - Record 1
(ID = 1)
Table B - Record 1
(ID =1 [this relates to Table A.ID]
PID = 12345
CID = 67899
Site = A)
Table C - Record 1
(PID = 12345 [this relates to Table B.PID]
CID = 67899
Site = A)
Table C - Record 2
(PID = 67899 [This relates to Table B.CID]
CID = 12345
Site = A)
Now, I need to relate Table A to Table B where A.ID = B.ID AND
((B.PID = C.PID AND B.CID = C.CID)
OR
(B.CID = C.PID AND B.PID = C.CID))
AND
B.SITE = C.SITE
There may or may NOT be related records in Table C. That's the problem. This is where I need the outer join to get the all the records of the 1st two joins and only those that apply from the last join.
Your help will be greatly appreciated.I'd create two queries, a join from b to c in each of those manners and then UNION ALL the results together.
drop table junk_a;
create table junk_a (
id number );
drop table junk_b;
create table junk_b (
id number,
pid number,
cid number,
site varchar2(80) );
drop table junk_c;
create table junk_c (
pid number,
cid number,
site varchar2(80) );
insert into junk_a values (1);
insert into junk_b values (1, 12345, 67899, 'A');
insert into junk_c values (12345, 67899, 'A');
insert into junk_c values (67899, 12345, 'A');
commit;
SELECT b.*,
c.site AS site_c
FROM junk_b b,
junk_c c
WHERE c.pid(+) = b.pid
AND c.cid(+) = b.cid
UNION ALL
SELECT b.*,
c.site AS site_c
FROM junk_b b,
junk_c c
WHERE c.cid(+) = b.pid
AND c.pid(+) = b.cid;
SELECT a.id,
bc.pid,
bc.cid,
bc.site,
bc.site_c
FROM junk_a a,
SELECT b.*,
c.site AS site_c
FROM junk_b b,
junk_c c
WHERE c.pid(+) = b.pid
AND c.cid(+) = b.cid
UNION ALL
SELECT b.*,
c.site AS site_c
FROM junk_b b,
junk_c c
WHERE c.cid(+) = b.pid
AND c.pid(+) = b.cid
) bc
WHERE bc.id(+) = a.id; -
I need your expert opinion on how to create a map with multiple conditions.
Hello.
I need your expert opinion on how to create a map with multiple conditions.
I have a procedure (which i cannot import or re-create in OWB due to the bug), so i am trying to create a map instead :-(
How can i create a cursors within the map?
My function creates table and cursor.
Then it will have to check for duplicates in the tables (the one created and another table) - the criteria for finding duplicates is a number of fields.I then need to place few different conditions (if some attributes are not available) and it has to load cursor based on this conditions. The next step is to fetch the data into the cursor based on what attributes are missing.
The next thing it will do is insert the data into table (if record doesn't exist), output the error in separate table is record is corrupted, or update the record with changed information.
In short i need to re-create match / merge but with conditions, iterations etc 'built into' it.
I can read up on available functions - it's just what would be the best options? and what would be the best approach to do so?
In my function i use %rowtype - but cannot use it in owb - so what would be the alternative? i don't really want to create a lot of variables and then have a nightmare of maintaing it. are there any tips regarding this?
having looked through Oracle dedupe - it's not really what i need because it is just DISTINCT.
I would appreciate any help / advise on this.
Thank you very muchthanks a lot for your reply - i will look into this option :-)
it is a bit more complicated now as i have to re-create the match / merge and then somehow 'tweak' it to achieve the result i need.
At the moment i am looking to breakdown the package into smaller chunks 'functions' and try creating the map that way.
Anyway, thank you very much for your suggestion. -
Maximum number of tables that can be outer joined with one table in a query
Hi All,
Iam new to sql, so can you please let me know What is the maximum number of tables that can be outer joined with one table in a query?
Thanks,
Srinisrinu2 wrote:
Iam new to sql, so can you please let me know What is the maximum number of tables that can be outer joined with one table in a query?
There is no limit to the number of tables you can outer join as long as you join them correctly.
SQL> with a as
2 (
3 select 1 id, 2 b_key, 3 c_key from dual union all
4 select 2 id, 1 b_key, 4 c_key from dual union all
5 select 3 id, 3 b_key, 1 c_key from dual union all
6 select 4 id, 4 b_key, 2 c_key from dual
7 ),
8 b as
9 (
10 select 1 id, 1 c_key2 from dual union all
11 select 2 id, 5 c_key2 from dual union all
12 select 3 id, 3 c_key2 from dual union all
13 select 4 id, 2 c_key2 from dual
14 ),
15 c as
16 (
17 select 1 key1, 1 key2, '1-1' dta from dual union all
18 select 1 key1, 2 key2, '1-2' dta from dual union all
19 select 1 key1, 3 key2, '1-3' dta from dual union all
20 select 1 key1, 4 key2, '1-4' dta from dual union all
21 select 2 key1, 1 key2, '2-1' dta from dual union all
22 select 2 key1, 2 key2, '2-2' dta from dual union all
23 select 2 key1, 3 key2, '2-3' dta from dual union all
24 select 2 key1, 4 key2, '2-4' dta from dual union all
25 select 3 key1, 1 key2, '3-1' dta from dual union all
26 select 3 key1, 2 key2, '3-2' dta from dual union all
27 select 3 key1, 3 key2, '3-3' dta from dual union all
28 select 3 key1, 4 key2, '3-4' dta from dual union all
29 select 4 key1, 1 key2, '4-1' dta from dual union all
30 select 4 key1, 2 key2, '4-2' dta from dual union all
31 select 4 key1, 3 key2, '4-3' dta from dual union all
32 select 4 key1, 4 key2, '4-4' dta from dual
33 )
34 select d.a_id, d.b_id, c.key1 as c_key1, c.key2 as c_key3, c.dta
35 from
36 c,
37 (
38 select
39 a.id as a_id, b.id as b_id, a.c_key, b.c_key2
40 from a, b
41 where a.b_key = b.id
42 ) d
43 where d.c_key = c.key1 (+)
44 and d.c_key2 = c.key2 (+);
A_ID B_ID C_KEY1 C_KEY3 DTA
3 3 1 3 1-3
4 4 2 2 2-2
2 1 4 1 4-1
1 2
SQL> -
Outer joins across multiple databases
I'm trying to join three tables: 2 from data warehouse and 1 from Siebel database in OBIEE. I create the physical and logical joins (no errors or warnings). The model looks like this: Account Address (table 1) -> Account (table 2) -> Siebel Customer Data (table 3)
I create two queries in Answers:
(1) Account.Number and Siebel.Address (the query works)
(2) Account Address.Zip, Account.Number, and Siebel.Address (the query gets the following error):
State: HY000. Code: 10058. [NQODBC] [SQL_STATE: HY000] [nQSError: 10058] A general error has occurred. [nQSError: 42019] Join condition, D901.c3 <> 0, contains predicates that are currently not supported for outer joins across multiple databases. (HY000)
Can someone help me understand why the join between the two databases works for the first query but when I add a second table it fails?
thanks...Either you can link the Oracle DB into Access (by using File/Get External Data/Link Tables)
or you have to simulate the join in Java by doing two separate queries and looping through the results. -
Oracle outer join on multiple tables throws error
Hi ,
We are using ansi joins with outer joins on multiple tables in oracle 9i.
Now these queries have to be used in Oracle8i.
Since Oracle8i does not support ansi sql we are replacing the ansi sql queries with the oracle joins.
On trying the same we found that the following query
select *from tab1 a, tab2 b, tab3 c where a.c1 = b.col1(+) and c.c2 = b.col2 (+)
throws the error
ORA-01417: a table may be outer joined to at most one other table.
Is there a way to simulate this query without using the outer joins on multiple tables?
thanksTry writing the query in this form:
select * from
(select t1.col1, t1.col2
from schema.table1 t1, schema.table2 t2
where t1.col1 = t2.col1(+)) t4,
schema.table3 t3 where t4.col2 = t3.col2(+)
In the subquery, you will have to list all the columns you want to see, and you will need to provide unique aliases for any columns with duplicate names. I tested this on 9i, and don't have an 8i system to work with, so I hope this helps. -
Outer join with BETWEEN clause
Hi All,
I have 2 tables (A and B) which i need to join. I need all records from table A and matching records from the table B. below is the structure.
TABLE A (total rows = 10)
ROW_WID
GL_DATE
LOCATION_CODE
TABLE B (total = 7)
ROW_WID
START_DATE
END_DATE
LOCATION_CODE
Initially, we were asked to join based on location_code. In the table B, some of the LOCATION_CODE are missing, which is present in table A.
We wrote below query
SELECT A.*, B.START_DATE, B.END_DATE
FROM A, B
WHERE A.LOCATION_CODE = B.LOCATION_CODE (+)
This gives 10 records, where 3 records have START_DATE and END_DATE NULL. because of outer join
It gave all records from the A table. It worked fine. Now i need to add one more condition where A.GL_DATE between B.START_DATE and B.END_DATE
If i write this
SELECT A.*, B.START_DATE, B.END_DATE
FROM A, B
WHERE A.LOCATION_CODE = B.LOCATION_CODE (+)
AND A.GL_DATE BETWEEN B.START_DATE and B.END_DATE
This gives me only 7 records. IS IT POSSIBLE TO ADD OUTER JOIN with BETWEEN clause.Hi All,
I'm in a similar situation,
I have a complex query, everything is working fine, except this part (I will simplify everything, removing other stuffs because I need help only on the following condition)
SELECT *
from transaction t, card c
where c.card_id = t.card_id (+)
and t.trn_date between to_date ('01/01/2012','dd/mm/yy') and ('01/01/2013,'dd/mm/yy')
How could i OUTER JOIN the between condition?
I tried with
and t.trn_date between to_date ('01/01/2012','dd/mm/yy') (+) and ('01/01/2013','dd/mm/yy') (+)
but returns a "missing expression" error.
Surely I'm missing some stupid thing about it, could you help me on this? (probably because I'm talking about parameters and I cannot put the outer join on a value)
How can I rewrite the condition in order to satisfy what I'm trying to accomplish?
Thanks in Advance,
Alex
Edited by: 981667 on 14-gen-2013 4.23
Edited by: 981667 on 14-gen-2013 4.24 -
MDX Calculated Member With Multiple Conditions
I need to create a calculated member in my cube that spans multiple dimensions. A current calculated member looks like this:
[Employee Hours Category].[Utilization Category].[NON-PTO], [Measures].[Employee Hours]
This calculated member returns all the hours an employee worked that are not PTO.
I need to select employee hours but with multiple conditions:
- [DIM BILL STATUS][Bill Status] equals 0
- [Employee Hours Time Category].[Time Category] equals "Client Facing"
- [DIM PROJECT].[Client] isn't like "Olson"
I know this is probably pretty easy, but I'm horrible with MDX!
Thank you!!
A. M. RobinsonThank you...
Your answer looks good but I was actually able to figure out most of it, but still looking how to incorporate a FILTER into the MDX. I would like to FILTER like this:
FILTER ([DIM Project].[Client].[Client].Members ,
NOT InStr([DIM Project].[Client].CurrentMember.MEMBER_NAME, "Olson")
Heres the MDX I have so far that is working fine:
([Employee Hours Time Category].[Time Category].&[Client Facing],
[DIM BILL STATUS].[Bill Status ID].&[1], [Measures].[Employee Hours])
Do you just wrap the whole MDX in the filter, and if so, how would that be formatted?
A. M. Robinson -
How to achieve an outer join with existsNode() function
I have a requirement to do an outer join with existsNode() function in my where clause. At present my where clause for join is like below
WHERE A.SOME_ID= “XYZ”
AND existsNode (B.SOMEXML_FEILD , …. ) = 1
AND existsNode (C.SOMEOTHERXML_FEILD , …. ) = 1
In this case if the existsNode fails on B or C, I still want data from A to be selected. How to rewrite this query to achieve that? I kinda want to achieve an outer joinHi,
is this what you are looking for:
SQL> with t as(select 1 id1,'A' name from dual union all
2 select 2 ,'B' name from dual union all
3 select 3,'C' from dual)
4 ,x as(select 1 id2,xmltype('<a>a</a>') xcol from dual union all
5 select 2 ,xmltype('<b>b</b>') xcol from dual)
6 select *
7 from t,x
8 where t.id1=x.id2(+)
9 and (existsNode(x.xcol,'/a')=1 or x.xcol is null);
ID1 N ID2 XCOL
1 A 1 <a>a</a>
3 C
SQL> spool off; -
Problem with outer join with filter on join column
Hi,
In physical layer I have one dimension and two facts, and there's an outer join between the facts.
dim_DATE ,
fact_1 ,
fact_2
Joins:
dim_DATE inner join fact_1 on dim_DATE.DATE = fact_1.DATE
fact_1 left outer join fact_2 on fact_1.DATE = fact_2.DATE and fact_1.SOME_ID = fact_2.SOME_ID
When I run a report with a date as a filter, OBIEE executes "optimized" physical SQL:
select fact1.X, fact2.Y
from
Fact_1 left outer join on fact_1.DATE = fact_2.DATE and fact_1.SOME_ID = fact_2.SOME_ID
where Fact_1.DATE = TO_DATE('2009-05-28' , 'YYYY-MM-DD' )
and Fact_2.DATE = TO_DATE('2009-05-28' , 'YYYY-MM-DD')
The filter on Fact_2.DATE effectively replaces outer join with inner.
Is there a way to disable this "optimization", which is actually very good for inner joins, but doesn't allow outer joins?
Thanks in advance,
Alex
Edited by: AM_1 on Aug 11, 2009 8:20 AMIf you want to perform a Fact-based partitioning with OBIEE (two fact with the same dimension), you have to :
* create in your physical layer for each fact table the joins with the dimension
* create in the Business Model layer ONE star schema with ONE logical fact table containing the columns of your two physical fact table
In this way when you choose minimal one column of your fact1 and one column of your fact2, OBIEE will perform two query against each fact table/dimension, join them with an OUTER JOIN and your problem will disappear.
Cheers
Nico -
Outer Join with Where Clause in LTS
HI all,
I have a requirement like this in ANSI SQL:
select p1.product_id, p1.product_name, p2.product_group
from product p1 left outer join product_group p2 on p1.product_id = p2.product_id
and p2.product_group = 'NEW'
In Regular SQL:
select p1.product_id, p1.product_name, p2.product_group
from product p1, product_group p2
WHERE p1.product_id *= p2.product_id and p2.product_group = 'NEW'
In OBIEE, I am using a left outer join between these two in Logical table Source, and also, Gave
p2.product_group = 'NEW' in WHERE clause of LTS.
This doesn't seem to solve purpose.
Do you have any idea how to convert WHERE clause in physical query that OBIEE is generating to something like
product p1 left outer join product_group p2 on p1.product_id = p2.product_id AND p2.product_group = 'NEW'
I am using Version 10.1.3.4.1
Creating an Opaque view would be my last option though.Hello
I have read your post and the responses as well. and I understand that you have issues with the Outer Join with where Clause in LTS.
Try this solution which worked for me (using your example ) -
1. In the Physical Layer created a Complex join between PRODUCT and PRODUCT_GROUP tables and use this join relationship :
PRODUCT.PROD_ID = PRODUCT_GROUP.PROD_ID AND PRODUCT_GROUP.GROUP_NAME = 'MECHANICAL'
2. In the General Tab of PRODUCT table LTS add PRODUCT_GROUP table and select Join Type as Left Outer Join.
3. Check Consistency and make sure there are no errors .
when you run a request you should see the following query generated -
select distinct T26908.PROD_ID as c1,
T26908.PROD_NAME as c2,
T26912.GROUP_NAME as c3
from
PRODUCT T26908 left outer join PRODUCT_GROUP T26912 On T26908.PROD_ID = T26912.PROD_ID and T26912.GROUP_NAME = 'MECHANICAL'
order by c1, c2, c3
Hope this works for you. If it does please mark this response as 'Correct' .
Good Luck. -
I have two tables
T1
name id
a 1
b 2
c 3
T2
id type
1 17
1 19
2 18
Now i want to join the two tables using left outer join and the condition on the table T2 is type=19. If for a particular id if type is present then the target table should get that type, else the column shud be empty. The target table shud look like this..
T3:
T1.name T2.id T2. type
a 1 19
b
c
the query I have used is
select T1.name,T2.id,T2.type from T1,T2
where T1.id=T2.id(+)
and T2.type=19
but its not working. Please suggest..
Thanks in advanceYou could also use an in-line view (your choice of join syntax):
SELECT t1.name, t2.id, t2.type
FROM t1,
(SELECT id, type FROM t2
WHERE type = 19) t2
WHERE T1.ID=T2.ID(+)John
Maybe you are looking for
-
How to get listitems from Sharepoint online using REST based on webid and listid
In my JavaScript code I have a webid and a listid in a sharepoint form page. I'm trying to construct a rest url to get to the infomation in the list. I cant figure out the url to get at the lists items. My WebID is 33213c5c-30e5-468c-87f7-52b48a7b6a3
-
Message not passed to Business Process Engine
Hi, I have a simple test scenario: File --> Integration Process --> File The process only has a reveive and a send step and sends the message further using the File adapter (this is just for testing purpose and no real-life scenario). This works corr
-
ResultSet problem plzz help me!! urgent!!
i am passing the result set to another jsp page through hidden variable.......... But it will return in string only.If i typecaste that......... It is giving error......
-
Create a Subscription without Notification Mail about the Creation
Hi, we have developed a room extension which automatically creates subscriptions for new room members for all room stores; the target channel is (and should be) the EMAIL channel. The problem now is that when a user is added to the room as a member,
-
Iphoto event not showing pictures
I had to restore from Time Machine my entire disk. However, since I have done the restore one event in Iphoto appears with no thumbnails and is grey yet all others are fine. When I open the grey event, all other photos in that event are blank (Grey)