OUTER JOIN not of Formate ansi
SELECT A.DEPTNO, B.DEPTNO, A.EMPNO, B.EMPNO FROM EMP A, B EMP1WHERE = B.DEPTNO A.DEPTNO (+)
I question as above
I want to recover the data by FULL OUTER join
No standard ansi formats
???
select a.deptno, b.deptno, a.empno, b.empno
from emp a, emp1 b
where a.deptno (+) = b.deptno
union all
select a.deptno, b.deptno, a.empno, b.empno
from emp a, emp1 b
where a.deptno = b.deptno (+)
Tags: Database
Similar Questions
-
Outer join not giving not correct result
I have two tables = > tab_child_tmp (product_id, region, child_val, mst_product) and
tab_master_tmp (master_product_id, master_val, area)
tab_child_tmp.mst_product is a foreign key referring to tab_master_tmp.master_product_id.
Currently, the tables are filled with values below
tab_child_tmp
PRODUCT_ID REGION CHILD_VAL MST_PRODUCT
-------------------------------------------------------------------------------------
Arm-01, CAL, 100, arm-Master
Arm-01, DEL, 222, arm-Master
Arm-01, CHEN, 55, arm-Master
Arm-02, MOM, 69, arm-Master
Arm-02, DEL, 90, arm-Master
tab_master_tmp
MST_PRODUCT REGION MASTER_VAL
Arm-Master, CAL, 390
Arm-Master, DEL, 300
Arm-Master, CHEN, 450
Arm-Master, MOTHER, 600
Now, I want to display the result in the below format
PRODUCT_ID REGION CHILD_VAL MASTER_VAL
-------------------------------------------------------------------------------------
1 arm-01, CAL, 100, 390
2 arm-01, DEL, 222, 300
3 arm-01, CHEN, 55, 450
4 arm-01, MA, 0, 600
5 arm-02, MOM, 69, 600
6 arm-02, DEL, 90, 300
7 arm-02, CHEN, 0, 450
8 arm-02, CAL, 0, 390
When I run the query below it is not above 4.7 and 8 rows. Can you please give correct sql to get the above result
SELECT
a.product_id,
NVL (a.Region, b.Region) geo.
NVL (a.child_val, 0) match_val,
b.master_val
Of
tab_child_tmp has,
tab_master_tmp b
WHERE
a.mst_product (+) = b.master_product AND
a.Region (+) = b.region
Thank youIn fact, I need to display product_id not the mst_product and if I run the query then the product_id from empty below
OK let's remove the next NULL.
SELECT max (b.PRODUCT_id) on (b.MST_PRODUCT partition),
a.REGION, nvl (b.CHILD_VAL, 0), a.MASTER_VAL
of tab_master_tmp one
Left Join tab_child_tmp b partition by (b.MST_PRODUCT)
We b.REGION = a.REGION
where b.MST_PRODUCT = a.MST_PRODUCT
/
-
query with outer join not dispalying the correct results
Hi all
I have a table that has a column called State it may be null or has the code that comes from the research b.When I use this query
Select a b.menaing
where a.status = b'lookup_code (+)
AND b.lookup_type = 'MTH_BUSINESS_FUNCTION'
AND b.LANGUAGE = USERENV ('LANG')
so I don't understand the lines of table a, where the status is null
and if I use the condition:
Select a b.menaing
where ((a.status IS NULL) OR)
(a.status = b.lookup_code
AND b.lookup_type = 'MTH_BUSINESS_FUNCTION'
AND b.LANGUAGE = USERENV ('LANG')))
Then, I get a lot of additional lines. You can soemone please tell me hwo to do (my query should display the menaing if the status column is empty, then it must show empty if not after to join the lookup table, it should show some sense)I don't get the rows in the table a, where the status is null
You must outerjoin each predicate referencing table b.:
select b.menaing from a,b where a.status=b.lookup_code(+) AND b.lookup_type(+)='MTH_BUSINESS_FUNCTION' AND b.LANGUAGE(+) = USERENV('LANG') /
Or use:
select b.menaing from a left join b on a.status=b.lookup_code(+) and b.lookup_type='MTH_BUSINESS_FUNCTION' and b.LANGUAGE = USERENV('LANG') /
SY.
-
Hi all
I have issues with the help of ANSI LEFT JOIN compared to Oracle (+). Below test I did the same thing.
Here Query1 return all records of 4 same records regardless of emp_name = 'A' where as Query2 returns 2 records of ep_name = 'A' which is correct.create table emp (emp_id number(10), emp_name varchar2(50)); create table courses (course_id number(10), emp_id number(10), course_name varchar2(50)); INSERT INTO EMP values(1,'A'); INSERT INTO EMP values(2,'B'); INSERT INTO EMP values(3,'C'); INSERT INTO COURSES values(1,1,'ORACLE'); INSERT INTO COURSES values(2,1,'JAVA'); INSERT INTO COURSES values(3,3,'C#'); --*Query 1 SELECT a.*, b.* FROM EMP a LEFT JOIN COURSES b ON a.emp_id = b.emp_id AND a.emp_name = 'A' --*Query 2 SELECT a.*, b.* FROM EMP a, COURSES b where a.emp_id = b.emp_id(+) and a.emp_name = 'A'
Is this correct? I'm confused if you use the standard ANSI OUTER JOINS or not.
I am using Oracle 11g
Thank you.Change your AND WHERE, in the style of ANSI, select:
SELECT a.*, b.* FROM EMP a LEFT JOIN COURSES b ON a.emp_id = b.emp_id WHERE a.emp_name = 'A'
Filters in the clause are those who use the (+) in the Oracle syntax.
Filters WITHOUT (+) in the Oracle syntax should be in the WHERE clause using the ANSI syntax.Published by: Kim Berg Hansen on September 23, 2011 08:03
-
Problem format (LEFT OUTER JOIN)?
THE addresses of Mutiple of return as a single record + current addresses
>
Hi all
I have to back student addresses home and dormitory under a single registration.
He had to go something like this:
In this format the desired:LAST_NAME FIRST_NAME ADDY_TYPE ADDRESS ZIP Smith John HOME 123 Awesome St 10003 Smith John DORM Oak Quad 10013
You also need to get their last addresses by date.LAST_NAME FIRST_NAME ADDY_TYPE ADDRESS ZIP ADDY_TYPE ADDRESS ZIP Smith John HOME 123 Awesome St 10003 DORM Oak Quad 10013
The database hold records of all students have places moving from dorm to dorm
and some permanent residence ("HOME") has changed as well.
To return only a DORM address and only a HOME address
for each student.
I'm looking at possibly a function BOX to put on a line/record and RANK BY() or DENSE_RANK to determine the last addresses.
Hope I'm making some sense and as always very grateful for any help. Thank you.
>
The correct code provided by Frank Kulash here:
I need to add a 'NATION' field, located on another table for the addresses of welcome for foreign students.WITH got_rnum AS ( SELECT last_name , first_name , addy_type , address , zip , ROW_NUMBER () OVER ( PARTITION BY last_name , first_name , addy_type ORDER BY addy_date DESC NULLS LAST ) AS rnum FROM table_x -- WHERE ... -- Any filtering goes here ) SELECT last_name , first_name , MIN (CASE WHEN addy_type = 'HOME' THEN address END) AS home_address , MIN (CASE WHEN addy_type = 'HOME' THEN zip END) AS home_zip , MIN (CASE WHEN addy_type = 'DORM' THEN address END) AS dorm_address , MIN (CASE WHEN addy_type = 'DORM' THEN zip END) AS dorm_zip FROM got_rnum WHERE rnum = 1 GROUP BY last_name , first_name ;
I made a LEFT OUTER JOIN with the table of the NATION and the release came out like this:
My desired output would be like this:LAST_NAME FIRST_NAME ADDY_TYPE ADDRESS ZIP NATION ADDY_TYPE ADDRESS ZIP Smith John HOME Rue Henry M1V 4F4 CANADA null null null Smith John null null null null DORM Oak Quad 10013
Maybe it's something I'm not right. What is the way I'm joining tables?LAST_NAME FIRST_NAME ADDY_TYPE ADDRESS ZIP NATION ADDY_TYPE ADDRESS ZIP Smith John HOME Rue Henry M1V 4F4 CANADA DORM Oak Quad 10013
As always very grateful for your contributions. Thank you.Give a glance to your group by, you group on the nation, but it has two values (NULL and CANADA). Try this way:
WITH got_rnum AS ( SELECT STUINFO_id , STUINFO_last_name , STUINFO_first_name , ADDRESSLIST_atyp_code , ADDRESSLIST_street_line1 , ADDRESSLIST_street_line2 , ADDRESSLIST_city , ADDRESSLIST_stat_code , ADDRESSLIST_zip , ADDRESSLIST_natn_code , NATION_nation , ROW_NUMBER () OVER ( PARTITION BY STUINFO_last_name , STUINFO_first_name , ADDRESSLIST_atyp_code ORDER BY ADDRESSLIST_from_date DESC NULLS LAST ) AS rnum FROM STUINFO JOIN CLASSROSTER ON STUINFO_pidm = CLASSROSTER_pidm JOIN ADDRESSLIST ON ADDRESSLIST_pidm = STUINFO_pidm LEFT OUTER JOIN NATION ON ADDRESSLIST_NATN_CODE =NATION_CODE -- The WHERE part determines if the student is currently enrolled in a class -- ADDRESSLIST_to_date is the last date the student will be living in that residence WHERE ADDRESSLIST_atyp_code IN ('PR', 'CA') and STUINFO_change_ind IS NULL and STUINFO_last_name !='Registrar' and CLASSROSTER_term_code='200909' and CLASSROSTER_PTRM_CODE IN ('D', 'D1', 'D2') and CLASSROSTER_CAMP_CODE='1' and (ADDRESSLIST_to_date is NULL OR ADDRESSLIST_TO_DATE > SYSDATE) ) SELECT STUINFO_id , STUINFO_last_name , STUINFO_first_name , MIN (CASE WHEN ADDRESSLIST_atyp_code = 'PR' THEN ADDRESSLIST_STREET_LINE1 END) AS PR_ADDRESSLIST_STREET_LINE1 , MIN (CASE WHEN ADDRESSLIST_atyp_code = 'PR' THEN ADDRESSLIST_STREET_LINE2 END) AS PR_ADDRESSLIST_STREET_LINE2 , MIN (CASE WHEN ADDRESSLIST_atyp_code = 'PR' THEN ADDRESSLIST_city END) AS PR_ADDRESSLIST_city , MIN (CASE WHEN ADDRESSLIST_atyp_code = 'PR' THEN ADDRESSLIST_stat_code END) AS PR_ADDRESSLIST_stat_code , MIN (CASE WHEN ADDRESSLIST_atyp_code = 'PR' THEN ADDRESSLIST_zip END) AS PR_ADDRESSLIST_zip , MIN (CASE WHEN ADDRESSLIST_natn_code IS NULL THEN ADDRESSLIST_natn_code END) AS PR_ADDRESSLIST_natn_code , MIN(NATION_nation) NATION_nation , MIN (CASE WHEN ADDRESSLIST_atyp_code = 'CA' THEN ADDRESSLIST_STREET_LINE1 END) AS CA_ADDRESSLIST_STREET_LINE1 , MIN (CASE WHEN ADDRESSLIST_atyp_code = 'CA' THEN ADDRESSLIST_STREET_LINE2 END) AS CA_ADDRESSLIST_STREET_LINE2 , MIN (CASE WHEN ADDRESSLIST_atyp_code = 'CA' THEN ADDRESSLIST_city END) AS CA_ADDRESSLIST_city , MIN (CASE WHEN ADDRESSLIST_atyp_code = 'CA' THEN ADDRESSLIST_stat_code END) AS CA_ADDRESSLIST_stat_code , MIN (CASE WHEN ADDRESSLIST_atyp_code = 'CA' THEN ADDRESSLIST_zip END) AS CA_ADDRESSLIST_zip FROM got_rnum WHERE rnum = 1 GROUP BY STUINFO_last_name , STUINFO_first_name , STUINFO_id ORDER BY STUINFO_last_name;
Max
-
Outer join does not not as expected left
Hi all
I have it here are three tables with values. Mentioned the under outer join query does not and behave like the inner query.
CREATE TABLE RET_FUND_FEE
(
NPTF VARCHAR2 (8 CHAR),
TPART VARCHAR2 (4 CHAR)
);
CREATE TABLE PART_PTF
(
Mf_Id VARCHAR2 (6 CHAR) NOT NULL,
TPARTS VARCHAR2 (4 CHAR) NOT NULL
);
CREATE TABLE TFC_FUNDS
(
NPTF VARCHAR2 (8 CHAR) NOT NULL,
MULTIFONDS_ID VARCHAR2 (6 CHAR)
);
INSERT INTO RET_FUND_FEE VALUES('111','A');
INSERT INTO RET_FUND_FEE VALUES('111','D');
INSERT INTO RET_FUND_FEE VALUES('111','E');
INSERT INTO PART_PTF VALUES ('MF1', 'A');
INSERT INTO PART_PTF VALUES ('MF1', 'B');
INSERT INTO PART_PTF VALUES('MF1','C');
INSERT INTO TFC_FUNDS VALUES('111','MF1');
INSERT INTO TFC_FUNDS VALUES('111','MF1');
INSERT INTO TFC_FUNDS VALUES('111','MF1');
SELECT A.TPART, B.TPARTS, A.NPTF, B.Mf_Id, C.MULTIFONDS_ID, C.NPTF
OF RET_FUND_FEE A, PART_PTF B, TFC_FUNDS C
WHERE A.NPTF = C.NPTF
AND C.MULTIFONDS_ID = B.Mf_Id
AND A.TPART = B.TPARTS (+)
AND C.MULTIFONDS_ID = 'MF1 '.
AND C.NPTF = '111'
Here, I expect all records in the RET_FUND_FEE table that I am using outer join.
But I'm only corresponding chronogram RET_FUND_FEE, PART_PTF as an inner join. Can you get it someone please let me know what lack us.
Is my version of oracle 11g
SELECT
A.TPART, B.TPARTS, A.NPTF, B.Mf_Id, C.MULTIFONDS_ID, C.NPTF
Of
PART_PTF B
Join
C TFC_FUNDS
on (C.MULTIFONDS_ID = B.Mf_Id
AND C.MULTIFONDS_ID = 'MF1 '.
AND C.NPTF = '111'
)
right outer join
RET_FUND_FEE HAS
on (A.TPART = B.TPARTS
and A.NPTF = C.NPTF) - added as correction
TPART TPARTS NPTF MF_ID MULTIFONDS_ID NPTF A A 111 MF1 MF1 111 A A 111 MF1 MF1 111 A A 111 MF1 MF1 111 E - 111 - - - D - 111 - - - or
SELECT A.TPART, d.TPARTS, A.NPTF, d.Mf_Id, d.MULTIFONDS_ID, d.NPTF
OF RET_FUND_FEE HAS
, (
Select
*
PART_PTF b, TFC_FUNDS C
where B.Mf_Id = C.MULTIFONDS_ID
AND C.MULTIFONDS_ID = 'MF1 '.
AND C.NPTF = '111'
) d
WHERE A.TPART = D.TPARTS (+)
and A.NPTF = D.NPTF (+) - added as a correction
Sorry had to correct the syntax oracle solution.
The first one was bad because it would return also B lines that have no match in C.
Sorry a correction more on these two approaches, missed the second predicate.
-
ORA-01719: outer join operator (+) not allowed in operand of GOLD or IN
I'm migrating a stored procedure (package) in Oracle 11 g. The SQL has an outer join, combined with a "GOLD":
Select a.row1, a.row2, b.row3, b.row4, c.row5, c.row6
schema1.table1 a, schema1.table2 b, schema2.table3 c
where
((c.orgunit = a.org (+) and b.newaccount (+) and TO_CHAR(c.createdatetime,'MM/DD/YYYY = c.account and c.feed = 'FOO' ') = TO_CHAR (SYSDATE, ' DD/MM/YYYY'))
or
((c.feed = 'BAR' and c.orgunit = a.org (+) and c.account b.newaccount (+) and TO_CHAR(c.createdatetime,'MM/DD/YYYY =') = TO_CHAR (SYSDATE, ' DD/MM/YYYY'));
The error is:
ORA-01719: outer join operator not allowed in operand of GOLD or IN
* Cause: Outer join appears in a clause or.
* Action: If A and B are predicates, to achieve the effect of (has or B).
I do not understand how to apply the suggested action to my query above. Can anyone provide a solution or a workaround?
Thank you.
your base table is c, a and b must be attached to the left
Select a.row1, a.row2, b.row3, b.row4, c.row5, c.row6
of schema2.table3 c
Join schema1.table1 left a c.orgunit on = a.org
c.account left join schema1.table2 b = b.newaccount
where c.createdatetime > = trunc (sysdate)
and c.createdatetime<>
and (c.feed = 'FOO' or c.feed = 'BAR');
-
What is the difference between NOT IN and LEFT OUTER JOIN
Hello
I searched the difference between everywhere. But his powerlessness.
Please tell me the differences.
Thanks in advance
KVBIt's like comparing apples and oranges.
NOT IN - exclude all lines matching the condition NOT IN (beware of NULL values).
JOIN EXTERNAL - return of rows from the inner table even if there is no corresponding row in the outer table.
SQL> -- NOT IN SQL> with x as 2 (select 1 col1 from dual union all 3 select 2 col1 from dual union all 4 select 3 col1 from dual) 5 , y as 6 (select 1 col1 from dual) 7 select * 8 from x 9 where col1 not in (1,2); COL1 ---------- 3 SQL> -- NOT IN (subquery) SQL> SQL> with x as 2 (select 1 col1 from dual union all 3 select 2 col1 from dual union all 4 select 3 col1 from dual) 5 , y as 6 (select 1 col1 from dual) 7 select * 8 from x 9 where col1 not in (select col1 from y); COL1 ---------- 2 3 SQL> -- OUTER JOIN SQL> with x as 2 (select 1 col1 from dual union all 3 select 2 col1 from dual union all 4 select 3 col1 from dual) 5 , y as 6 (select 1 col1 from dual) 7 select * 8 from x 9 left outer join 10 y 11 on x.col1 = y.col1; COL1 COL1 ---------- ---------- 1 1 3 2 SQL> -- Maybe it helps to contrast LOJ with just JOIN? SQL> with x as 2 (select 1 col1 from dual union all 3 select 2 col1 from dual union all 4 select 3 col1 from dual) 5 , y as 6 (select 1 col1 from dual) 7 select * 8 from x 9 join y 10 on x.col1 = y.col1; COL1 COL1 ---------- ---------- 1 1 SQL>
-
Left Outer Join does not work why?
Hello
I have a question I want to return all the id group grp_id table and count and give me a count of all "active" members in the Member table. There are a few members who are not active in the table of members who belong to groups in the grp_id table. I still want a record returned for these grpid, but since there is no active members for these groups, I would like a zero as the mbr_count. An active mbr is the one whose eff_dt is less than the date of the day and whose exp_dt is greater than today's date.
I have listed the query below, which returns active records mbr, but unfortunately does not return a grpid (as in my example of data) is not an active member (grpid: has ""). I have also provided the DDL for both tables as well as some examples of data that gives me the (Incorrect) results, that I posted. I have also posted what I need (the 'Correct' results).
Thanks for any help... (I use PL/SQL)
THE QUERY I USE:
=============
SELECT
G00.grpid,
Count (M00.grpid) mbr_count
Of
g00 grp_id
LEFT OUTER JOIN
m00 MBR on
G00.grpid = m00.grpid
WHERE
M00.eff_dt < sysdate
AND
M00.exp_dt > sysdate
GROUP BY
G00.grpid
It gives me results like:
INCORRECT RESULTS:
===============
GRPID MBR_COUNT
A 2
B 2
C 1
I want to see is:
CORRECT RESULTS
===============
GRPID MBR_COUNT
A 2
B 2
C 1
D 0
Here's the DOF and the sample data:
create table grp_id (grpid varchar (1))
insert into grp_id values ('A')
insert into grp_id values ('B')
insert into grp_id values ('C')
insert into grp_id values (')
Commit
create table mbr (mbr_name varchar (10), varchar (1) grpid, eff_dt date, exp_dt date)
insert into values of mbr ('BRAND', 'A', to_date (January 1, 2011 ',' DD-MM-YYYY '), to_date (July 1, 2011 ',' DD-MM-YYYY '))
insert into values of mbr ('BRAND', 'A', to_date (July 1, 2011 ',' DD-MM-YYYY '), to_date (1 January 2012 ',' DD-MM-YYYY '))
insert into values of mbr ('MARTY', 'A', to_date (January 1, 2011 ',' DD-MM-YYYY '), to_date (July 1, 2011 ',' DD-MM-YYYY '))
insert into values of mbr ('MARTY', 'A', to_date (July 1, 2011 ',' DD-MM-YYYY '), to_date (1 January 2012 ',' DD-MM-YYYY '))
insert into values of mbr ('FRANK', 'B', to_date (January 1, 2011 ',' DD-MM-YYYY '), to_date (July 1, 2011 ',' DD-MM-YYYY '))
insert into values of mbr ('FRANK', 'B', to_date (July 1, 2011 ',' DD-MM-YYYY '), to_date (1 January 2012 ',' DD-MM-YYYY '))
insert into values of mbr ('MARY', 'B', to_date (January 1, 2011 ',' DD-MM-YYYY '), to_date (July 1, 2011 ',' DD-MM-YYYY '))
insert into values of mbr ('MARY', 'B', to_date (July 1, 2011 ',' DD-MM-YYYY '), to_date (1 January 2012 ',' DD-MM-YYYY '))
insert into values of mbr ('JOHN', 'C', to_date (January 1, 2011 ',' DD-MM-YYYY '), to_date (July 1, 2011 ',' DD-MM-YYYY '))
insert into values of mbr ('JOHN', 'C', to_date (July 1, 2011 ',' DD-MM-YYYY '), to_date (1 January 2012 ',' DD-MM-YYYY '))
insert into values of mbr ("NOAM" 'd', to_date (January 1, 2011 ',' DD-MM-YYYY '), to_date (July 1, 2011 ',' DD-MM-YYYY ') ")Thanks for the script, shame on the missing semicolon :)
Your date restrictions are implemented as "filter predicates" rather than "join predicates.
that is the difference between a place ANDS extra o in the JOIN clause.SQL> SELECT 2 g00.grpid, 3 count(m00.grpid) mbr_count 4 FROM 5 grp_id g00 6 LEFT OUTER JOIN 7 mbr m00 on 8 g00.grpid = m00.grpid 9 WHERE 10 m00.eff_dt < sysdate 11 AND 12 m00.exp_dt > sysdate 13 GROUP BY 14 g00.grpid 15 / G MBR_COUNT - ---------- A 4 B 4 C 2 SQL> SELECT 2 g00.grpid, 3 count(m00.grpid) mbr_count 4 FROM 5 grp_id g00 6 LEFT OUTER JOIN 7 mbr m00 on 8 g00.grpid = m00.grpid 9 AND 10 m00.eff_dt < sysdate 11 AND 12 m00.exp_dt > sysdate 13 GROUP BY 14 g00.grpid; G MBR_COUNT - ---------- D 0 A 4 B 4 C 2 SQL>
-
Outer join is not retrieve the correct values
Hi, I have a problem to recover some data from this query with outer join:
SELECT count (incident_id), range_2 of
(by selecting range_2 in apps.aaa_table),
(Select inc.incident_id,
XXN2B_RESOLUTION_RANGE (2, ROUND (((TO_DATE (inc. INCIDENT_ATTRIBUTE_7, «hh24:mi:ss jj/mm/yyyy»)-inc. INC_RESPONDED_BY_DATE) * 24), 2)) VARIES
Inc. stuff
Inc. INVENTORY_ITEM_ID,
prom_dt. Iptv_Sumptom - S? µpt? µA
OF cs_incidents_all_b inc.,.
cs_incidents_all_tl tl,
cs_sr_type_mapping m,
fnd_responsibility RESP,
ntt xxntt.xxntt_incidents_support,
xxntt.xxntt_incidents ntt_inc,
XXe.xxe_tt_promitheas_dt prom_dt,
20th. Xxe_Cs_Int_Sla als
WHERE inc.incident_id = tl.incident_id
AND tl. LANGUAGE = 'EL '.
AND inc.incident_type_id = m.incident_type_id
AND resp.responsibility_key IN (select SV. S fnd_flex_value_sets FLEX_VALUE, FND_FLEX_VALUES SV
where s.FLEX_VALUE_SET_NAME = 'XXNTT_RESPONSIBILITIES. '
AND S.FLEX_VALUE_SET_ID = SV. FLEX_VALUE_SET_ID)
AND m.responsibility_id = resp.responsibility_id
AND resp.end_date is null
AND inc.incident_number = ntt.incident_number (+)
AND inc.incident_number = ntt_inc.incident_number (+)
AND inc.incident_id = prom_dt.incident_id (+)
AND inc.incident_number = sla. Incident_Number (+)
- and don't like '%0:00% ' TOTAL_INACT_SLA_DURATION
(Inc. INC_RESPONDED_BY_DATE is not null AND INCIDENT_ATTRIBUTE_7 is not null)
) b.
(select * from xxntt_custom_hierarchy)
Union
Select eidos null null omada, null product_categiory, stuff, null, null, inv_item_descripiption, null, tautopoihsh, inv_item_id double null null symptom
) c
where a.range_2 = b.ranges (+)
and c.INV_ITEM_ID (+) = b.INVENTORY_ITEM_ID
and c.CATEGORY_ID (+) = b.CATEGORY_ID
and c.SYMPTOM (+) = b.IPTV_SUMPTOM
and c.OMADA = 'A '.
Range_2 group
This request is composed by 3 dataset: a, b and c
the data group is a fixed list of values (LOV): range_2 = "0-2h','2-4h','4-6h','6-8h','8-10h','10-12h','12-14h','14-16h','16-18h','18-20h".
the dataset b retrieve a list of the incident_id and their related ranges (calculated with the XXN2B_RESOLUTION_RANGE function)
the c dataset is just a filter on the b of dataset to retrieve only the incident_id who belong to the group "A".
I want to reach is this: always see the full list of values 'range_2', even if I do not have incident_id with a particular range.
That's why I put the condition: a.range_2 = b.ranges (+)
.. .but it does not work... I don't see the incident_id which have the scope inside the LOV... instead I want to see also if there is incident_id without a range to the LOV.
Range_2 grouping, I see:
! http://www.freeimagehosting.NET/uploads/d900035c11.jpg!
Instead of
! http://www.freeimagehosting.NET/uploads/99a75dfca4.jpg!
Can someone help me understand where is the error?
Thanks in advance
AlexHi Alex,
I think you need to externally join the final predicate, thus:
.. and c.OMADA(+) = 'A' ..
Concerning
Peter -
That IS NULL is done by replacing the NOT EXISTS operator with an outer join?
DB version: 10 gr 2
An example of searchoracle.target.com
The query that contains a NOT EXISTS operator
is replaced by an equivalent outer join querySELECT M.ModulId, M.Modul FROM MODULE M WHERE NOT EXISTS ( SELECT PROJEKTMODUL.IdModul FROM PROJEKTMODUL WHERE M.ModulId = PROJEKTMODUL.IdModul AND PROJEKTMODUL.IdProjekt = 23 )
I do not understand whatselect distinct M.ModulId , M.Modul from MODULE M left outer join PROJEKTMODUL on M.ModulId = PROJEKTMODUL.IdModul and PROJEKTMODUL.IdProjekt = 23 where PROJEKTMODUL.IdProjekt is null
fact in the above rewritten query.PROJEKTMODUL.IdProjekt is null
He is to perform an anti-jointure. As far as I know Oracle (starting with version 10g - I thought that release 1) rewritten a Join Anti that resembles your second query of your request NOT EXISTS and NOT IN.
Look at the results of the query without the predicate IS NULL and see what records (from this set) must be selected to show the same results as the first query. Areas of interest match the predicate IS NULL.
-
Hello
Pls help me my request. I tried the following, but it does not give the expected results.
Tab1
EmplId, RepDt, Code, Hrs
1/100,1/2009,199,8
1/100,1/2009,200,4
1/100,1/2009,255,3
200,1/1/2009,200,4
100.5/1/2009,199,8
Tab2
EmplId, RepDt, Code, Hrs
1/100,1/2009,200,6
200,1/1/2009,200,3
I need output like this - 4 rows - need of all the rows from TAB1 when EMPLID, REPDT match TAB2, field values: need at a time when Code is also, when emlid, correspondence of the date, the Code missing so need A hrs, display ZERO as Tab2 hours.
1/100,1/2009,199,8,0 - did not exist is not in tab2, so hrs Tab2 is ZERO
1/100,1/2009,200,4,6 - Emplid, RepDt, Code match existence in Tab2, Tab1 Hrs 8, 6 Hrs Tab2
1/100,1/2009,255,3,0 - did not exist is not in Tab2, so Tab2 hrs is equal to ZERO
200,1/1/2009,200,4,3 - Emplid, Repdt, Code Match existed in Tab2, 4 Hrs of Tab1, Tab2 3 Hrs
We are in 10g, Oracle.
I tried the following
T1. EmplId = T2.emplid AND T1.repdt = T2.repdt AND T1.code, T2.code = (+) - returns the unique corresponding lines, 2 rows.
Pls help.
Thanks in advance.
Published by: NL 23 February 2009 09:20Hello
See the Boneist first message in this thread:
select t1.emplid, t1.repdt, t1.code, t1.hrs, nvl(t2.hrs, 0) from tab1 t1, tab2 t2 where t1.emplid = t2.emplid (+) and t1.repdt = t2.repdt (+) and t1.code = t2.code (+) and (t1.emplid, t1.repdt) in (select emplid, repdt from tab2) order by repdt, emplid, code;
As Boneist said, this fact corresponds to option (b)
"(b) do just an outer join, with a condition EXISTS (or IN) in the WHERE clause to find corresponding repdts.
The(+)
an outer join are signs.
-
outer join does not give the expected results (missing documents)
Hello
I have problem with outer join in OBIEE 10 g.
I'm testing it on the model of simplified database
STAT table with some statistics of TYPEs
stat_date, id_type, num
..
..
26/03/2003, 20: 1
26/03/2003, 21: 1
26/03/2003, 23: 1
26/03/2003, 24, 1
26/03/2003, 25, 1
..
27/03/2003, 22, 1 <-different date here
..
..
Table TYPES
ID_type
..
..
20
21
22
23
24
25
..
..
Physical model
STAT >-TYPES
AM.
F1 (only Digital STAT table column (agg. County))
D1 (STAT_DATE of the STAT table column only)
D2 (source TYPES)
D1 - inner join - < F1
D2 - left outer join - < F1
I would like to create simple report filtered by date with number of each type.
I want to get this result
ID_type County
.. ..
.. ..
20 1
21 1
22 null
23 1
24 1
25 1
.. ..
.. ..
But I get this
ID_type County
.. ..
.. ..
20 1
21 1
23 1
24 1
25 1
.. ..
.. ..
ID_type 22 is missing
!!!
I NORMALLY GET RESULT ONLY IF I DELETE RECORD ' 27/03/2003 22' OF MY FACT TABLE.
!!!
I have the filter on the date column D1
STAT_DATE = 26/03/2003 or STAT_DATE is null
BI Server running this SQL query
Select distinct D1.c1 as c1,
D1. C2 C2
Of
(select count (T17840. NUM) in c1.
T17867.ID_TYPE C2
Of
Left outer join of TYPES T17867
STAT T17840 on T17840.ID_TYPE = T17867.ID_TYPE
where (T17840. STAT_DATE in (TO_DATE ('2003-03-26', 'YYYY-MM-DD')) or T17840. STAT_DATE is null)
T17867.ID_TYPE group
) D1
Can you give me some advice?
Thank youHi cardel,
I think that you can achieve your goal if you build a dimension of the array STAT form, you can create a table Alias in the physical layer and then to join the table of facts (external to the left). In this way, I think that you can solve your problem.
Let me know.
Kind regards
Gianluca -
Hi all
I use under version
Connected to Oracle Database 11g Express Edition Release 11.2.0.2.0
SQL > SELECT E.ENAME,.
2 D.DEPTNO,
3 D.LOC
4. TO EMP E,.
DEPT 5 D
6. WHERE = E.DEPTNO D.DEPTNO (+);
ENAME, DEPTNO LOC
---------- ------ -------------
DALLAS SMITH 20
ALLEN 30 CHICAGO
WARD 30 CHICAGO
20 DALLAS JONES
MARTIN 30 CHICAGO
BLAKE 30 CHICAGO
CLARK 10 NEW YORK
SCOTT 20 DALLAS
THE 10 NEW YORK KING
TURNER 30 CHICAGO
20 DALLAS ADAMS
JAMES 30 CHICAGO
FORD 20 DALLAS
MILLER 10 NEW YORK
40 BOSTON
15 selected lines
-----------------------------------------------------------------------------------------------------------------------------
SQL > SELECT E.ENAME,.
2 D.DEPTNO,
3 D.LOC
4. TO EMP E
5 LEFT OUTER JOIN
D 6 DEPT
7. THE E.DEPTNO = D.DEPTNO;
ENAME, DEPTNO LOC
---------- ------ -------------
MILLER 10 NEW YORK
THE 10 NEW YORK KING
CLARK 10 NEW YORK
FORD 20 DALLAS
20 DALLAS ADAMS
SCOTT 20 DALLAS
20 DALLAS JONES
DALLAS SMITH 20
JAMES 30 CHICAGO
TURNER 30 CHICAGO
BLAKE 30 CHICAGO
MARTIN 30 CHICAGO
WARD 30 CHICAGO
ALLEN 30 CHICAGO
14 selected lines
My doubt is both are same query is the same, is in ansi format and is in the format of the Oracle,.
but the results are different.
For the first query null is coming for unmatched records in the dept table
but in the second query, it does not come
Thank you
Hello
2947022 wrote:
Hi all
I use under version
Connected to Oracle Database 11g Express Edition Release 11.2.0.2.0
SQL > SELECT E.ENAME,.
2 D.DEPTNO,
3 D.LOC
4. TO EMP E,.
DEPT 5 D
6. WHERE = E.DEPTNO D.DEPTNO (+);
ENAME, DEPTNO LOC
---------- ------ -------------
DALLAS SMITH 20
ALLEN 30 CHICAGO
WARD 30 CHICAGO
20 DALLAS JONES
MARTIN 30 CHICAGO
BLAKE 30 CHICAGO
CLARK 10 NEW YORK
SCOTT 20 DALLAS
THE 10 NEW YORK KING
TURNER 30 CHICAGO
20 DALLAS ADAMS
JAMES 30 CHICAGO
FORD 20 DALLAS
MILLER 10 NEW YORK
40 BOSTON
15 selected lines
-----------------------------------------------------------------------------------------------------------------------------
SQL > SELECT E.ENAME,.
2 D.DEPTNO,
3 D.LOC
4. TO EMP E
5 LEFT OUTER JOIN
D 6 DEPT
7. THE E.DEPTNO = D.DEPTNO;
ENAME, DEPTNO LOC
---------- ------ -------------
MILLER 10 NEW YORK
THE 10 NEW YORK KING
CLARK 10 NEW YORK
FORD 20 DALLAS
20 DALLAS ADAMS
SCOTT 20 DALLAS
20 DALLAS JONES
DALLAS SMITH 20
JAMES 30 CHICAGO
TURNER 30 CHICAGO
BLAKE 30 CHICAGO
MARTIN 30 CHICAGO
WARD 30 CHICAGO
ALLEN 30 CHICAGO
14 selected lines
My doubt is both are same query is the same, is in ansi format and is in the format of the Oracle,.
but the results are different.
For the first query null is coming for unmatched records in the dept table
but in the second query, it does not come
Thank you
In fact, these requests are not the same.
The first is to find all the lines of the Department, with the corresponding lines of PGE (when there are). This is equivalent to «FROM dept LEFT OUTER JOIN emp...» ».
The second is to find all the rows in the emp of the lines of the Department (when there are any). This is equivalent to «...» WHERE e.deptno = d.deptno (+).
-
create table test1 (col1 varchar2 (10));
create table test2 (col1 varchar2 (10));
Insert into test1 values('1');
Insert into test1 values('2');
Insert into test1 values('3');
Insert into test2 values('1');
Select * from test1, test2 where test1.col1 = test2.col1 (+) and test1.col1 = 1;
Select * from test1 test2 outer join left on test1.col1 = test2.col1 and test1.col1 = 1;
Why are these two different results?
Hello
user13648517 wrote:
create table test1 (col1 varchar2 (10));
create table test2 (col1 varchar2 (10));
Insert into test1 values('1');
Insert into test1 values('2');
Insert into test1 values('3');
Insert into test2 values('1');
Select * from test1, test2 where test1.col1 = test2.col1 (+) and test1.col1 = 1;
Select * from test1 test2 outer join left on test1.col1 = test2.col1 and test1.col1 = 1;
Why are these two different results?
In the first query, the condition
test1.Col1 = 1
is not part of the join condition. The outer join is done first and then the lines where the test1.col1 <> 1 are deleted.
In the second query, this condition is part of the join condition. Test1 lines are not removed results just don't not outer join conditions.
This shows one of the many benefits of the ANSI join syntax, especially when well formatted:
Select *.
of test1
outer join test2 left test1.col1 = test2.col1
and test1.col1 = 1;
This clearly shows that the condition "test1.col1 = 1" is part of the join condition.
Maybe you are looking for
-
What is the difference between Apple Watch sport and Apple Watch?
What is the difference between Apple Watch Sport42mm space aluminum case gray with Strip black sports and Apple Watch 42 mm space with black Sport band black steel box?
-
No recovery expert on Satellite A100-237 option?
Hello I own a laptop Satellite A100-237 which, after a long struggle with attacks from viruses and Trojans, needs a system recovery. I have a package of product recovery 2-CD with Windows XP Home edition with SP2 and all of the drivers/tools etc and
-
Satellite of swapping screen LCD L850-150 to another with more resolution?
Hello I am owner of a Toshiba L850-150, with a screen resolution of 1366 x 768 and I want to know if it is possible to change the Lcd display to another with more resolution, say a panel that is capable of displaying a resolution of full HD 1920 * 10
-
I bought my Moto-X on the release of Verizon, a white, 16 GB version. My question is has this promotion Google Drive available when I bought the phone and if not, is there a chance that I'm able to receive? 50 GB of storage is really nice for a phone
-
LaserJet 1022n: 1022n printer does not print with Win 10
Tried to install on new computer Win 10 1022n. Connected via USB. Downloaded all the HP stuff with driver and found that I could run p; program to clean the print head. Try to print the test page for the printer properties and receive the error mess