Join Condition between tables
Hi all,
Is it possible to propose a join condition (using SQ02) between two fields of two tables other than what is proposed by the system?
Thanks
Sandeep
Hi Sandeep,
You can very much match other fields of two tables in SQ02.
1. Goto SQ02
2. Give the infoset name
3. Goto change mode
4. Press the Join button, it will display the join conditions between the two tables.
5. Press Join Conditions, it will propose the system generated join conditions
with key fields
6. If you want to match your own fields other than the key fields you can just
point the mouse pointer on the field of the first table and just drag it to the field
of the second table. It will create a join condition.
7. Save the infoset.
Regards,
Jayaram...
Similar Messages
-
Join condition between PO_REQUISITION_HEADERS_ALL and WF_NOTIFICATIONS
Hi,
Could anyone tell me what is the join condition between PO_REQUISITION_HEADERS_ALL and WF_NOTIFICATIONS?
I joined these two tables by WF_NOTIFICATIONS.ITEM_KEY = PO_REQUISITION_HEADERS_ALL .WF_ITEM_KEY.But I cannot found some approved requisitions item key in WF_NOTIFICATIONS table.
Please help.
I paste my query below:
SELECT PRH.ORG_ID ORG_ID,
WF.ITEM_KEY,
WF.FROM_ROLE,
PRH.WF_ITEM_KEY,
WF.RECIPIENT_ROLE APPROVERS_NAME,
TRUNC(NVL(PRH.APPROVED_DATE, '')) DATE_APPROVED,
WF.SUBJECT SUBJECT,
PRH.DESCRIPTION REQ_DESC,
PRH.SEGMENT1,
(SUM(NVL(PRL.AMOUNT, 0)) +
SUM(NVL(PRL.UNIT_PRICE, 0) * NVL(PRL.QUANTITY, 0))) REQ_AMT,
GL.SEGMENT1 || '.' || GL.SEGMENT2 || '.' || GL.SEGMENT3 || '.' ||
GL.SEGMENT4 || '.' || GL.SEGMENT5 || '.' || GL.SEGMENT6 || '.' ||
GL.SEGMENT7 || '.' || GL.SEGMENT8 CHARGE_ACCT
FROM APPS.WF_NOTIFICATIONS WF,
APPS.PO_REQUISITION_HEADERS_ALL PRH,
APPS.PO_REQUISITION_LINES_ALL PRL,
APPS.PO_REQ_DISTRIBUTIONS_ALL PRD,
APPS.GL_CODE_COMBINATIONS GL
WHERE WF.FROM_ROLE IN ('GHAWKINS', 'GHALVERSON', 'NCERNOTTA', 'DCOLLOPY', 'RHAY')
AND BEGIN_DATE > SYSDATE - 60
AND WF.MESSAGE_TYPE = 'REQAPPRV'
AND WF.ITEM_KEY = PRH.WF_ITEM_KEY --added
AND PRH.AUTHORIZATION_STATUS = 'APPROVED'
AND PRL.REQUISITION_HEADER_ID = PRH.REQUISITION_HEADER_ID
AND PRD.REQUISITION_LINE_ID = PRL.REQUISITION_LINE_ID
AND PRD.CODE_COMBINATION_ID = GL.CODE_COMBINATION_ID
GROUP BY PRH.ORG_ID,
WF.ITEM_KEY,
WF.FROM_ROLE,
PRH.WF_ITEM_KEY,
WF.BEGIN_DATE,
WF.SUBJECT,
WF.RECIPIENT_ROLE,
PRH.APPROVED_DATE,
PRH.DESCRIPTION,
PRH.SEGMENT1,
PRL.REQUISITION_HEADER_ID,
GL.SEGMENT1 || '.' || GL.SEGMENT2 || '.' || GL.SEGMENT3 || '.' ||
GL.SEGMENT4 || '.' || GL.SEGMENT5 || '.' || GL.SEGMENT6 || '.' ||
GL.SEGMENT7 || '.' || GL.SEGMENT8Pl see if these MOS Docs can help -
603232.1 - How to Diagnose Purchasing Document Approval Routing
579522.1 - Forward Document Form FAQ
431767.1 - How To View Requisition From The Email Notifications For Which Workflow Data Is Purged
HTH
Srini -
Hi,
What is the Join condition between mtl_system_items_b and mtl_onhand_quantities_detail?
Thanks & Regards,
Hari BabuPlease see the query in (Consolidate Onhand Quantity /Sum Quantity Zero in MTL_ONHAND_QUANTITIES_DETAIL (MOQD) / Concurrent Program Consolidate Inventory Onhand Quantities / Datafix for 0 Quantity Displayed For Finished Goods (Doc ID 353345.1)), is shows how to join those 2 tables.
http://etrm.oracle.com
Thanks,
Hussein -
Identify join condition between any two table.
Hi,
I have set of tables. I don't know whether these tables are interlinked or not. I need to identify the underlying join condition in. As per my knowledge if my datasource is based upon infoset query , then I can go to SQ02 and find the underlying join condition. But in this case, I have only table names. How do i find whether they are interlinked or not.
Thanks in advance
Regards
SnehasishHi ,
Go to SE11 t-code
select VIEW radio button
give view name start with Z.select create button
select databseview radiobutton. select copy button.
it opens a view creation window.
give table names in leftside .
select RELATIONSHIP button. -
Reg: Join Conditions for Tables to create a View for Generic Extraction
Hi Experts,
Am trying to extract the data from Solman, for this purpose am creating a Generic Extractor based on three tables. So, can anyone please help me out by providing the join conditions to create a view based upon the following three tables,
1. CRM_ORDERM_H
2. DNOD_NOTIF
3. DNOD_NOTIF_S
Anyways i require the following fields in the extractor finally:
CRM CHANGED AT
GUID
SAP COMPONENT
RELEASE
REPORTED BY
These are the some of the major fields that i require in the final extractior. Please help me out ASAP with the table join conditions..
Will Assign Points for the helpfull answer...
Thanks,
Gattu.Hi,
I don't know the table CRM_ORDERM_H however you can link DNOD_NOTIF and DNOD_NOTIF_S
DNOD_NOTIF_S-CLIENT = DNOD_NOTIF-CLIENT
DNOD_NOTIF_S-GUIDS = DNOD_NOTIF-GUIDS
For the third table could you please paste here its definition like the hereunder?
Transp. table DNOD_NOTIF Active
Short Text Notification Header
Field KeyInitData element Data TyLengthDecimaShort Text
CLIENT X X MANDT CLNT 3 0Client
GUIDH X X DNOT_GUIDH RAW 16 0GUID Notification
.INCLUDE DNOS_NOTIF_INT STRU 0 0Notifications (Header, Internal Fields)
OBJNR DNOT_OBJNR CHAR 22 0Status Management Object Number
STATUS DNOT_STATUS CHAR 1 0Notification Status
DELETED DNOT_DELE_N CHAR 1 0Deletion Indicator Notification
PROCESSOR DNOT_PROC CHAR 12 0Current Processor
TYPE_PROC DNOT_TYPE_PRC CHAR 2 0Type of Processor
REPORTER DNOT_REPORTER CHAR 12 0Reported By
TYPE_REPO DNOT_TYPE_REP CHAR 2 0Type of Notification Creator
CREA_TSTMP DNOT_CREA_TSTMP DEC 15 0Entry Time Stamp
CHNG_TSTMP DNOT_CHNG_TSTMP DEC 15 0Time of Last Change
START_TSTMP DNOT_START_TSTMPDEC 15 0Initial Response Time - Time Stamp
END_TSTMP DNOT_END_TSTMP DEC 15 0Requested End of Processing - Time Stamp
CLO_TSTMP DNOT_CLO_TSTMP DEC 15 0Completion Time Stamp
.INCLUDE DNOS_NOTIF_EXT STRU 0 0Notifications (Header, External Fields)
NUMB DNOT_NUM CHAR 12 0Notification Number (External)
REFNUM DNOT_REFNUM CHAR 20 0External Reference Number
TYPE_NOTIF DNOT_TYPE_N CHAR 6 0Message category
CATEGORY DNOT_CATEGORY CHAR 12 0Topic, Area
SUBJECT DNOT_SUBJECT CHAR 60 0Re:
PRIORITY DNOT_PRIORITY CHAR 1 0Notification priority
LANGUAGE DNOT_LANG_N LANG 1 0Notification Language
hope this helps...
Olivier. -
Hello,
My requirment to extract data from the below HR Tables to BW.
Fot that purpose i am developing a VIEW based on these tables...
what are fields that are present in all tables as i can use them in by join condition
HR Tables
HRP1000
HRP1001
HRP1007
HRP1011
HRP1005
ThanksHi Suresh,
Thanks for the info provided.
I didn't understand exactly what your saying with regards to
'Why don't you simply dump these into soam staging Tables on your BW system & then build your Views/Cubes off the staging tables'
Could you please explain me in a bit details.
Actually my reporting requirments is to have the following fields
Field Name - Table Name
OBJID -HRP1000
OTYPE-HRP1000
STATUS-HRP1007
MOAVG- HRP1011
SOBID-HRP1001
TRFGI -HRP1005
BEGDA-HRP1000
tHANKS -
Join conditions in Multiprovider and Infoset
Hi experts,
1. I am using the multiprovider 0IC_MC01 which contains the cube 0IC_C03 and 0MATERIAL.
I want to know the join conditions between these two infoproviders in the Multiprovider. How and where to get this info?
2. Similarly, I've a Infoset(custom created) which contains 2 DSOs. I want to know the join conditions between these 2 DSOs in the Infoset.
Please give a hint on this.Hi,
pls go through the following steps and u can get the required info form the links provided...
1. Create an InfoArea to which you want to assign the new MultiProvider.
Choose Modeling ® InfoProvider.
2. In the context menu of the InfoArea, choose Create MultiProvider.
3. Enter a technical name and a description.
4. Choose Create.
5. Select the InfoProvider that you want to form the MultiProvider. Choose Continue. The MultiProvider screen appears.
6. Use drag and drop to transfer the required InfoObjects into your MultiProvider. You can also transfer entire dimensions.
7. Use Identify Characteristics and Select Key Figures to make InfoObject assignments between MultiProviders and InfoProviders.
http://help.sap.com/saphelp_nw70/helpdata/EN/cf/bc734190ba137de10000000a155106/frameset.htm
for infoset u can hav the deatils from below
http://help.sap.com/saphelp_nw70/helpdata/EN/d2/cb466d455611d189710000e8322d00/frameset.htm
regards,
rudra.
Assign points if useful -
hello all,
can anyone help me write an outer join b/n the two tables below. The joining condition has if's and or's.
table 1 has 2 million rows, table 2 is very small
TABLE1
CUSTOMER_ID
CITY
STATE
1
SKOKIE
IL
2
CHICAGO
IL
3
CARY
NC
ERIE
PA
PHILLY
PA
CHARLOTE
NC
2 MILLION
CITYXY
STATEX
TABLE2
CITY
STATE
CONTACT
IL
OJO
ERIE
BRITT
PA
MIKE
PITTSBURG
PA
HILTON
N043
TAT
affi
B
affi
R
b0b
Q
b0b
CHARLOTE
NC
b0b
problem :: for all the data in table1, I need to find out the CONTACT from table 2 And the join condition would be as below
1. either both TABLE1.CITY=TABLE2.CITY AND TABLE1.STATE=TABLE2.STATE and get CONTACT
OR
2. TABLE1.CITY=TABLE2.CITY AND TABLE2.STATE IS NULL and get the value of CONTACT
OR
3. TABLE1.STATE=TABLE2.STATE AND TABLE2.CITY is null and get the value of CONTACT
I need a query like this
SELECT A.CUSTOMER_ID, A.CITY, A.STATE, B.CONTACT
FROM TABLE1 A, TABLE2 B
WHERE (join condition fitting in the 3 condition mentioned above)Dear OP,
Do you want something like this?
> with t1 as
-- Start of SAMPLE DATA
(select 1 CUSTOMER_ID, 'SKOKIE' CITY, 'IL' STATE from dual union
select 2, 'CHICAGO', 'IL' from dual union
select 3, 'CARY', 'NC' from dual union
select 4, 'ERIE', 'PA' from dual union
select 5, 'PHILLY', 'PA' from dual union
select 6, 'CHARLOTE', 'NC' from dual)
t2 as
(select null CITY, 'IL' STATE, 'OJO' CONTACT from dual union
select 'ERIE', null, 'BRITT' from dual union
select null, 'PA', 'MIKE' from dual union
select 'PITTSBURG', 'PA', 'HILTON' from dual union
select 'N043', 'TAT', 'affi' from dual union
select null,'B', 'affi' from dual union
select null,'R', 'b0b' from dual union
select null,'Q', 'b0b' from dual union
select 'CHARLOTE', 'NC', 'b0b' from dual
--- END IF SAMPLE Data
select * from t1 full outer join t2
on ( nvl(t1.city,t2.city) = nvl(t2.city,t1.city)
and nvl(t1.state,t2.state) = nvl(t2.state,t1.state) )
order by 1,2,3,4
CUSTOMER_ID CITY STATE CITY STATE CONTACT
1 SKOKIE IL IL OJO
2 CHICAGO IL IL OJO
3 CARY NC
4 ERIE PA ERIE BRITT
4 ERIE PA PA MIKE
5 PHILLY PA PA MIKE
6 CHARLOTE NC CHARLOTE NC b0b
N043 TAT affi
PITTSBURG PA HILTON
B affi
Q b0b
R b0b
12 rows selected
Elapsed: 00:00:00.112
Hope this is helpful. If not please let us know what is you desired result (sample) if your data was like above?
vr,
Sudhakar -
Creating a Relation between two Blocks - the Join Condition [SOLVED]
Hi. I'm trying to create a Relation between my TTMS_Audit table and my Bundle_Exceptions table. This is the join condition:
ttms_audit.primary_key_values = bundle_exceptions.project_cd||','||bundle_exceptions.bundle||','||bundle_exceptions.exception_cd
And I get the following error:
FRM-15004: Error while parsing join condition
Does anyone know if my concatenated values in the Join Condition are allowed? Can I even do this? Is there a logical work around?Got it.
I first created the concatenated values as a non-base table item on my form:
:NBT_PRIMARY_KEY_VALUES := :bundle_exceptions.project_cd||','||:bundle_exceptions.bundle||','||:bundle_exceptions.exception_cd;
Then my join condition simply became:
ttms_audit.primary_key_values = bundle_exceptions.nbt_primary_key_values -
Join conditions for the given tables
Hi,
I would like to join the below tables
FA_INVOICE_DETAILS_V FID
,AP_INVOICE_PAYMENT_HISTORY_V AIP
,PO_DISTRIBUTIONS_all PD
,AP_BATCHES_ALL AB
,PO_HEADERS_ALL POH
,PO_LINES_ALL POL
,FA_ADDITIONS_V FAA
can anyone give me the conditions to join the above tables. Its an urgent please suggest me
Thanks in advanceOnly you can know how to join those tables. We don't know your business, your data, or your requirements.
If you would like us to help you, you need to provide the definitions of all the tables and which columns match between these tables. Then you have to tell us if you want inner joins, outer joins, theta joins, etc.
Please see the following link:
Urgency in online postings -
ABAP query- unable to delete the join between tables
Im unable to delete the join between two tables. when i right clicked on the join then it gives two options:
1. Display join condition
2. Remove join condition
both these options are grey in color so i cant select them. how can i remove join?goto SQ02 and enter infoset and goto change mode agagin select change mode and click the join then select and delete link...
-
More than one join condition for 2 tables in obiee
Hello,
I am using obiee 11g.
There are 2 tables tableA and tableB where the join condition is like (tableA.col1=tableB.col1) or (tableA.col1 is null and tableB.col1 is null)
where should i do these type of joins.
I tried putting in physcial layer->f(x) but giving error like here only columns an d opertaors are allowed.
Thanksok here it goes.
I have a tableA with columns col1(pk),col2 and other columns
I have tableB with columns col1(pk),col2..Only these 2 columns.
Now distinct tableA.col2 values are put in tableB.col2. For those distinct values i have put the tableB.col1 values.
Now tableA.col2 as well as tableB.col2 can be null beacuse there may be null values in tableA.col2.
Now in tableB i have added one more row which has col1 as value and col2 as null.
Now when in physical layer when i do tableA.col2=tableB.col2 i dont get the null values.
What i want is whenever the tableA.col2 and tableB.col2 is null then take tableB.col1 for those vales.
So when i query i do
select * from tableA,tableB where
((tableA.col2=tableB.col2) or (tableA.col2 is null and tableB.col2 is null))
What i want is when i do a join i should be able to give this OR condition in rpd thats it.
because when i do in where clause of content tab it goes like a AND condition and not OR.
Thanks
Edited by: user123 on Jul 5, 2011 1:57 PM -
How to get data from a table in a condition between twomonth
hai friends
I have a query that is i want to get data from a table based on a condition between two months in a format of char column
Ex
I have a column called from_month in the format of 'mon/yyyy'(already converted from date')
then the second column is to_month in the same format 'mon/yyyy'
now i wiil select from_month and to_month like
from month jan/2009
to month mar/2010
how to use between of two months in the format of char.Please tell me how to get two different month between data.Hi,
This may be of help.
Remember Pointless has made a point ;) (worth millions)
If possible , DO NOT store dates as strings or numbers.Let dates be dates.
WITH dat AS
(SELECT ' THIS IS JAN' x,to_char(to_date('01-JAN-2009','DD-MON-YYYY'),'mon/yyyy') y FROM dual UNION
SELECT ' THIS IS FEB' x,to_char(to_date('01-FEB-2009','DD-MON-YYYY'),'mon/yyyy') y FROM dual UNION
SELECT ' THIS IS MAR' x,to_char(to_date('01-MAR-2009','DD-MON-YYYY'),'mon/yyyy') y FROM dual UNION
SELECT ' THIS IS APR' x,to_char(to_date('01-APR-2009','DD-MON-YYYY'),'mon/yyyy') y FROM dual UNION
SELECT ' THIS IS MAY' x,to_char(to_date('01-MAY-2009','DD-MON-YYYY'),'mon/yyyy') y FROM dual UNION
SELECT ' THIS IS JUN' x,to_char(to_date('01-JUN-2009','DD-MON-YYYY'),'mon/yyyy') y FROM dual UNION
SELECT ' THIS IS JUL' x,to_char(to_date('01-JUL-2009','DD-MON-YYYY'),'mon/yyyy') y FROM dual UNION
SELECT ' THIS IS AUG' x,to_char(to_date('01-AUG-2009','DD-MON-YYYY'),'mon/yyyy') y FROM dual UNION
SELECT ' THIS IS SEP' x,to_char(to_date('01-SEP-2009','DD-MON-YYYY'),'mon/yyyy') y FROM dual UNION
SELECT ' THIS IS OCT' x,to_char(to_date('01-OCT-2009','DD-MON-YYYY'),'mon/yyyy') y FROM dual UNION
SELECT ' THIS IS NOV' x,to_char(to_date('01-NOV-2009','DD-MON-YYYY'),'mon/yyyy') y FROM dual)
SELECT * FROM dat
WHERE to_date(y,'mon/yyyy') BETWEEN to_date('01 jan 2009','dd mon yyyy') AND to_date('01 mar 2009','dd mon yyyy')Cheers!!!
Bhushan -
Dynamic SQL Joining between tables and Primary keys being configured within master tables
Team , Thanks for your help in advance !
I'm looking out to code a dynamic SQL which should refer Master tables for table names and Primary keys and then Join for insertion into target tables .
EG:
INSERT INTO HUB.dbo.lp_order
SELECT *
FROM del.dbo.lp_order t1
where not exists ( select *
from hub.dbo.lp_order tw
where t1.order_id = t2.order_id )
SET @rows = @@ROWCOUNT
PRINT 'Table: lp_order; Inserted Records: '+ Cast(@rows AS VARCHAR)
-- Please note Databse names are going to remain the same but table names and join conditions on keys
-- should vary for each table(s) being configured in master tables
Sample of Master configuration tables with table info and PK Info :
Table Info
Table_info_ID Table_Name
1 lp_order
7 lp__transition_record
Table_PK_Info
Table_PK_Info_ID Table_info_ID PK_Column_Name
2 1 order_id
8 7 transition_record_id
There can be more than one join condition for each table
Thanks you !
Rajkumar YeluguHi Rajkumar,
It is glad to hear that you figured the question out by yourself.
There's a flaw with your while loop in your sample code, just in case you hadn't noticed that, please see below.
--In this case, it goes to infinite loop
DECLARE @T TABLE(ID INT)
INSERT INTO @T VALUES(1),(3),(2)
DECLARE @ID INT
SELECT @ID = MIN(ID) FROM @T
WHILE @ID IS NOT NULL
PRINT @ID
SELECT @ID =ID FROM @T WHERE ID > @ID
So a cursor would be the appropriate option in your case, please reference below.
DECLARE @Table_Info TABLE
Table_info_ID INT,
Table_Name VARCHAR(99)
INSERT INTO @Table_Info VALUES(1,'lp_order'),(7,'lp__transition_record');
DECLARE @Table_PK_Info TABLE
Table_PK_Info_ID INT,
Table_info_ID INT,
PK_Column_Name VARCHAR(99)
INSERT INTO @Table_PK_Info VALUES(2,1,'order_id'),(8,7,'transition_record_id'),(3,1,'order_id2')
DECLARE @SQL NVarchar(MAX),
@ID INT,
@Table_Name VARCHAR(20),
@whereCondition VARCHAR(99)
DECLARE cur_Tabel_Info CURSOR
FOR SELECT Table_info_ID,Table_Name FROM @Table_Info
OPEN cur_Tabel_Info
FETCH NEXT FROM cur_Tabel_Info
INTO @ID, @Table_Name
WHILE @@FETCH_STATUS = 0
BEGIN
SELECT @whereCondition =ISNULL(@whereCondition+' AND ','') +'t1.'+PK_Column_Name+'='+'t2.'+PK_Column_Name FROM @Table_PK_Info WHERE Table_info_ID=@ID
SET @SQL = 'INSERT INTO hub.dbo.'+@Table_Name+'
SELECT * FROM del.dbo.'+@Table_Name+' AS T1
WHERE NOT EXISTS (
SELECT *
FROM hub.dbo.'+@Table_Name+' AS T2
WHERE '+@whereCondition+')'
SELECT @SQL
--EXEC(@SQL)
SET @whereCondition = NULL
FETCH NEXT FROM cur_Tabel_Info
INTO @ID, @Table_Name
END
Supposing you had noticed and fixed the flaw, your answer sharing is always welcome.
If you have any question, feel free to let me know.
Eric Zhang
TechNet Community Support -
Difference between join conditions using NVL and not using NVL
Hi,
I have a join condition in one of the applications as follows.
NVL(RQ.out_mesg_id,0) = NVL(RS.out_mesg_id,0)How is it different without using NVL function. What is the internal execution difference.
RQ.out_mesg_id = RS.out_mesg_idWill there be any difference in Performance and also in the query output.
Regards,
PaboluPabolu wrote:
Hi,
I have a join condition in one of the applications as follows.
NVL(RQ.out_mesg_id,0) = NVL(RS.out_mesg_id,0)How is it different without using NVL function. What is the internal execution difference.
RQ.out_mesg_id = RS.out_mesg_idWill there be any difference in Performance and also in the query output.
Regards,
PaboluI suppose that's a bit of a trick question (or could be).
If the column is allowed to be NULL, then your 2 queries are NOT equivalent, so comparing isn't useful since presumably you can only have one correct result :)
However, if RQ and RS (no idea what the table names are) are both defined as having a NOT NULL constraint on the column out_mesg_id (ignoring the possibility of column level masking possible with the use of VPD here) then the optimizer could do better if you rewrote the query without the use of NVL (this would of course depend on your tables, indexes, etc ... i am merely showing you that it COULD make a difference).
SQL> select * from v$version;
BANNER
Oracle Database 10g Express Edition Release 10.2.0.1.0 - Product
PL/SQL Release 10.2.0.1.0 - Production
CORE 10.2.0.1.0 Production
TNS for 32-bit Windows: Version 10.2.0.1.0 - Production
NLSRTL Version 10.2.0.1.0 - Production
SQL>
SQL> create table t1 as
2 select level as col1, case when mod(level, 10) = 0 then null else mod(level, 10) end as col2
3 from dual connect by level <= 1000;
Table created.
SQL>
SQL> alter table t1 add constraint t1_pk primary key (col1);
Table altered.
SQL>
SQL> create index t1_i_001 on t1 (col2);
Index created.
SQL>
SQL> exec dbms_stats.gather_table_stats(user, 'T1', cascade => true);
PL/SQL procedure successfully completed.
SQL>
SQL> create table t2 as
2 select level as col1, case when mod(level, 100) = 0 then null else mod(level, 100) end as col2
3 from dual connect by level <= 1000;
Table created.
SQL>
SQL> alter table t2 add constraint t2_pk primary key (col1);
Table altered.
SQL>
SQL> create index t2_i_001 on t2 (col2);
Index created.
SQL>
SQL> exec dbms_stats.gather_table_stats(user, 'T2', cascade => true);
PL/SQL procedure successfully completed.
SQL>
SQL> --query using NVL
SQL> explain plan for
2 select count(*)
3 from t1, t2
4 where nvl(t1.col1, 0) = nvl(t2.col1, 0)
5 /
Explained.
SQL>
SQL> SELECT * FROM table(DBMS_XPLAN.DISPLAY);
PLAN_TABLE_OUTPUT
Plan hash value: 663667122
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 1 | 8 | 5 (20)| 00:00:01 |
| 1 | SORT AGGREGATE | | 1 | 8 | | |
|* 2 | HASH JOIN | | 1000 | 8000 | 5 (20)| 00:00:01 |
| 3 | INDEX FAST FULL SCAN| T1_PK | 1000 | 4000 | 2 (0)| 00:00:01 |
| 4 | INDEX FAST FULL SCAN| T2_PK | 1000 | 4000 | 2 (0)| 00:00:01 |
PLAN_TABLE_OUTPUT
Predicate Information (identified by operation id):
2 - access(NVL("T1"."COL1",0)=NVL("T2"."COL1",0))
16 rows selected.
SQL>
SQL> --verbose version of NVL
SQL> explain plan for
2 select count(*)
3 from t1, t2
4 where t1.col1 = t2.col1
5 or ( (t1.col1 is null and t2.col1 = 0) or (t2.col1 is null and t1.col1 = 0) or (t1.col1 is null and t2.col1 is null) )
6 /
Explained.
SQL>
SQL> SELECT * FROM table(DBMS_XPLAN.DISPLAY);
PLAN_TABLE_OUTPUT
Plan hash value: 1043818223
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 1 | 8 | 2 (0)| 00:00:01 |
| 1 | SORT AGGREGATE | | 1 | 8 | | |
| 2 | NESTED LOOPS | | 1000 | 8000 | 2 (0)| 00:00:01 |
| 3 | INDEX FAST FULL SCAN| T1_PK | 1000 | 4000 | 2 (0)| 00:00:01 |
|* 4 | INDEX UNIQUE SCAN | T2_PK | 1 | 4 | 0 (0)| 00:00:01 |
PLAN_TABLE_OUTPUT
Predicate Information (identified by operation id):
4 - access("T1"."COL1"="T2"."COL1")
16 rows selected.So if we compare the 'verbose' version of the query, in the "predicate information" section of the explain you can see that the optimizer was able to completely ignore the
or ( (t1.col1 is null and t2.col1 = 0) or (t2.col1 is null and t1.col1 = 0) or (t1.col1 is null and t2.col1 is null) ) condition since it knows that neither t1.col1 NOR t2.col1 columns can be null (by definition), and because of this we get a slightly different index access choice.
Maybe you are looking for
-
Dear Experts, I have urgent issue in here after many years of using SAP . Suddenly all the GI STO cant be cancelled due to error: errorcode: M7152 for item 0001 of purch. order &, no goods issue can post. is there anything missing ?
-
My Apple Loops are not selectable. Can anyone help me with this please?
Whenever I open up my Apple Loops on Logic Pro X, they are not selectable. I have tried reinstalling the program and reinstalling the loops, but that did not work. Any help would be much appreciated. Thanks!
-
Firefox crashes when I try to access the 'tools/Add-on menu'
I am trying to determine which add-on causes firefox to crash. When I click on 'Tools', then "add-on', it crashes every time. What can I do to find out which add-on is faulty?
-
Hi all, I've been fighting this for 2 days now. I'm trying to check if an account is already shared with a team before modifying or granting the access. I noticed at first that when I shared, and then checked at the next run, Sharing and Assign privs
-
Hello there! Pages is slow on my iPhone 4S
Hello there! My Pages is slow on my iPhone 4S. Would anybody know how it can work faster, like the former Pages vrsion used to work on my iPhone 4S?