difference between Inner Join join natural r
Experts,
I'm trying to understand the difference between Natural Join and inner join.
Inner join: the following query provides 106 lines based on two tables
SQL > SELECT EMPLOYEE_ID EID, last NAME, DEPT_NAME DEPARTMENT_NAME
2 EMPLOYEES A, B MINISTRIES
3. WHERE A.DEPARTMENT_ID = B.DEPARTMENT_ID
4 order employee_id;
Natural Join: This is the combination or combined result of all the columns in both tables.
When I run the Sub statement, it combines employees and the table from department of a HR schema and provides only 32 ranks
SQL > select employe_id, first_name, department_name
2 departments of NATURAL JOIN employees;
EMPLOYEE_ID NAME DEPARTMENT_NAME
----------- -------------------- -------------------
Neena 101 Executive
Lex 102 Executive
104 Bruce IT
David 105 HE
question: why the NATURAL JOIN query omit the employee_id 103 and on what basis it omit a few other employee_id
Thanks in advance
Hello
The main difference is that INNER JOIN is used in real life; NATURAL JOIN is used only in textbooks.
More rigorously, FRANCKLIN JOIN is an inner join, involving all the columns that have the same name. The hr.departments and hr.employees have 2 columns with the same name: department_id and manager_id, so
OF hr.departments d
NATURAL JOIN e hr.employees
is equivalent to
OF hr.departments d
INNER JOIN hr.employees e ON e.department_id = d.deparment_id
AND e.manager_id = d.manager_id
or, using the old join syntax
OF hr.departments d
e hr.employees
WHERE e.department_id = d.deparment_id
AND e.manager_id = d.manager_id
Tags: Database
Similar Questions
-
Difference between Inner join and right outer join...
Which is precisely the difference between an Inner join and right outer join...JOIN INTERNAL:-to return all rows from the two tables where there is a football game. That is to say. the table resulting from all the rows and columns will have values.
AND
RIGHT OUTER JOIN:-Returns all rows in the second table, even if there is no match in the first table.
-
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>
-
outer join: difference between two queries
Below two queries which should give the same results in my opinion. I want that all records of u_protocol and the pval.u_protocol_variable_value value if necessary.
Why the outer join in query2 does not work as in query1?
Query1:
Query2:select p.u_protocol_id, i.u_protocol_variable_value from lims_sys.u_protocol p, ( select pval.u_protocol_id, pval.u_protocol_variable_value from lims_sys.u_protocol_variable pvar, lims_sys.u_protocol_value_user pval where pvar.u_protocol_variable_id = pval.u_protocol_variable_id and pvar.name = 'VALUE_Protocol_Group' ) i where p.u_protocol_id = i.u_protocol_id (+)
select prt.u_protocol_id, pval.u_protocol_variable_value from lims_sys.u_protocol prt, lims_sys.u_protocol_variable pvar, lims_sys.u_protocol_value_user pval where pvar.u_protocol_variable_id = pval.u_protocol_variable_id and prt.u_protocol_id = pval.u_protocol_id (+) and pvar.name = 'VALUE_Protocol_Group'
Hello
When you perform an outer join, all conditions on the tables in option must be outer join conditions. Otherwise, the effect is an inner join.
There is one exception: cascade of outer joins, external-junction b of a and c is outside attached to b. In this case, in the b - c join only columns of c are marked with the sign +.Re - write to obtain the same results as query1, query2 like this:
select prt.u_protocol_id , pval.u_protocol_variable_value from lims_sys.u_protocol prt , lims_sys.u_protocol_variable pvar , lims_sys.u_protocol_value_user pval where pvar.u_protocol_variable_id (+) = pval.u_protocol_variable_id -- cascading outer join and prt.u_protocol_id = pval.u_protocol_id (+) and pvar.name (+) = 'VALUE_Protocol_Group' -- (+) added ;
I find the syntax ANSI easier to use for all the joins and much easier for outer joins.
-
Reg: Diff between Right Join and Right Outer Join
Dear all,
Kindly help me to find the difference between the two queries below where the results are the same.
SELECT * FROM emp RIGHT JOIN dept WE emp.deptno = dept.deptno;
SELECT * FROM emp RIGHT OUTER JOIN dept WE emp.deptno = dept.deptno;Thank you
Both are same
-
Hey in the 10 Report Builder Query Builder, I got an error:
Of tblFacility INNER JOIN tblStateProvince ON tblFacility.OIDStateProvince = tblStateProvince What is java.swl.SQLException: [Macromedia] [SequeLinkJDBC Driver] [ODBC Socket] [Microsoft] [ODBC Microsoft Access driver] Join expression not taken in charge.
Why?
Report Designer will automatically join tables only if you have defined a relationship between them in your database.
In Report Designer, you can easily create a join by dragging a field from one table to the related field in the other table. It couldn't be simpler.
See you soon
Eddie
-
Hi all
I have a few tables with samples as:
As you can see I have Hotels with basic information, persons of type hotel_people (1:baby, 2:young and 3:Adult), which contains the type of people that each hotel can accommodate with min max age and hotel_service that contains the info from the number of rooms and the amount of people that can be in each room.CREATE OR REPLACE TABLE hotel ( hotel_id int NOT NULL , hotel_name varchar2(50) NULL , hotel_address varchar2(100) NULL ); CREATE OR REPLACE TABLE people_type ( people_type_id int NOT NULL , type_des varchar2(30) NOT NULL ); CREATE OR REPLACE TABLE hotel_people ( hotel_id int NOT NULL , people_type_id int NOT NULL , age_min int NULL , age_max int NULL ); CREATE OR REPLACE TABLE hotel_service ( hotel_id int NOT NULL , qty_room int NOT NULL , qty_people int NOT NULL, qty_people_extra int NOT NULL ); insert into hotel(hotel_id, hotel_name, hotel_address) values(1,'hotel1','hotel1 address1'); insert into hotel(hotel_id, hotel_name, hotel_address) values(2,'hotel2','hotel2 address2'); insert into hotel(hotel_id, hotel_name, hotel_address) values(3,'hotel3','hotel3 address3'); insert into hotel(hotel_id, hotel_name, hotel_address) values(4,'hotel4','hotel4 address4'); insert into people_type (people_type_id, type_des) values (1,'Baby'); insert into people_type (people_type_id, type_des) values (2,'Young'); insert into people_type (people_type_id, type_des) values (3,'Adult'); insert into hotel_people (hotel_id, people_type_id, age_min, age_max) values (1,1,0,2); insert into hotel_people (hotel_id, people_type_id, age_min, age_max) values (1,2,3,10); insert into hotel_people (hotel_id, people_type_id, age_min, age_max) values (1,3,11,200); insert into hotel_people (hotel_id, people_type_id, age_min, age_max) values (2,2,3,17); insert into hotel_people (hotel_id, people_type_id, age_min, age_max) values (2,3,18,200); insert into hotel_people (hotel_id, people_type_id, age_min, age_max) values (3,3,18,200); insert into hotel_people (hotel_id, people_type_id, age_min, age_max) values (4,1,0,2); insert into hotel_people (hotel_id, people_type_id, age_min, age_max) values (4,2,3,10); insert into hotel_people (hotel_id, people_type_id, age_min, age_max) values (4,3,11,200); insert into hotel_service (hotel_id, qty_room, qty_people,qty_people_extra) values (1,10,2,1); insert into hotel_service (hotel_id, qty_room, qty_people,qty_people_extra) values (1,5,4,0); insert into hotel_service (hotel_id, qty_room, qty_people,qty_people_extra) values (2,6,2,1); insert into hotel_service (hotel_id, qty_room, qty_people,qty_people_extra) values (2,12,3,1); insert into hotel_service (hotel_id, qty_room, qty_people,qty_people_extra) values (3,10,2,1); insert into hotel_service (hotel_id, qty_room, qty_people,qty_people_extra) values (3,5,4,0); insert into hotel_service (hotel_id, qty_room, qty_people,qty_people_extra) values (4,6,2,1); insert into hotel_service (hotel_id, qty_room, qty_people,qty_people_extra) values (4,12,3,1);
I'm trying to get the records that match my condition as:
1. I want to get the hotels that can accommodate 4 pieces with adults of 3 for each room.
2 get hotels that can accommodate 6 rooms 2 where 2 of the bedrooms can have 1 young (3 people per room) and young people 9 years.
For 1:
For 2:select h.hotel_id, h.hotel_name, ss.qty_room, t.type_des, ss.qty_people, p.age_min, p.age_max from hotel h inner join hotel_service ss on h.hotel_id = ss.hotel_id inner join hotel_people p on h.hotel_id = p.hotel_id inner join people_type t on p.people_type_id = t.people_type_id where ss.qty_room >= 4 and t.people_type_id = 3 and ss.qty_people >= 3
This does not work, the start of the query becomes more complex if I try to search for multiple rooms with a different number of people and children of different ages.select h.hotel_id, h.hotel_name, ss.qty_room, t.type_des, ss.qty_people, p.age_min, p.age_max from hotel h inner join hotel_service ss on h.hotel_id = ss.hotel_id inner join hotel_people p on h.hotel_id = p.hotel_id inner join people_type t on p.people_type_id = t.people_type_id where ss.qty_room >= 6 and ss.qty_people >= 3 and t.people_type_id in (2,3) and 9 between p.age_min and p.age_max
Can anyone help with this?
Thank you
Published by: user9542267 on April 3, 2012 22:26Hello
user9542267 wrote:
... Yes, what I need is a hotel that can accommodate TWO adults and youth. What do you mean by two copies?Right now I read something on the Grand Duke by Gilbert. I also have a book with the complete works of Gilbert, so I can leave it open, and when I see a reference in the commentary, I see exactly what the author is talking about in the book. However, when the comment compares some parts of this game to the other plays of Gilbert, The Yeomen of the Guard , it gets hard, because I have to keep changing the pages in the complete works, and I can't see both at the same time. It would be much easier if I could get a full second copy of the work; then I could leave a copy of the Grand Duke and leave the other copy open to The Yeomen of the Guard . This is similar to what you should do with the table of hotel_people, and what I do with the table scott.emp below.
Imagine (using tables in the scott schema) you have to find the departments where both an analyst and a clerk to work.
This:SELECT DISTINCT d.* FROM scott.dept d JOIN scott.emp e ON d.deptno = e.deptno WHERE job IN ('ANALYST', 'CLERK') ORDER BY d.deptno ;
product
DEPTNO DNAME LOC ------ -------------- ------------- 10 ACCOUNTING NEW YORK 20 RESEARCH DALLAS 30 SALES CHICAGO
because all these departments have either an analyst or a clerk. However, only deptno = 20 a time .
If, instead of a single table of big job, you have a separate table for each Olympic Games, then you might do something like this:SELECT DISTINCT d.* FROM scott.dept d JOIN analyst a ON d.deptno = a.deptno JOIN clerk c ON d.deptno = c.deptno ORDER BY d.deptno ;
Of course, you don't have tables separated like that, but you could generate result sets who behaved as separte tables, for example:
WITH analyst AS ( SELECT * FROM scott.emp WHERE job = 'ANALYST' ) , clerk AS ( SELECT * FROM scott.emp WHERE job = 'CLERK' ) SELECT DISTINCT d.* FROM scott.dept d JOIN analyst a ON d.deptno = a.deptno JOIN clerk c ON d.deptno = c.deptno ORDER BY d.deptno ;
Note that the main request is exactly what I posted earlier.
What produces the right output:DEPTNO DNAME LOC ------ -------------- ------------- 20 RESEARCH DALLAS
There is no need to actually generate separate result sets, however. You can use two copies of the table scott.emp in the same query, as follows:
SELECT DISTINCT d.* FROM scott.dept d JOIN scott.emp a ON d.deptno = a.deptno JOIN scott.emp c ON d.deptno = c.deptno WHERE a.job = 'ANALYST' AND c.job = 'CLERK' ORDER BY d.deptno ;
-
INNER JOIN vs WHERE (+) rating
I am trying to determine the best way to write joins in Oracle. I'm a guy from SQL Server, and I'm used to writing
Select t1.c1 from table1 t1 INNER JOIN table2 t2 ON t1.c1 = t2.c1
I have been informed that the Oracle compiler prefers the sign (+) rating to join columns in which the clause. I have also been informed that Oracle has deprecated notation plue for INNER JOIN scoring in 10g. What is the real answer?I personally never did a comparison of performance between the two.
I've always preferred the ANSI rating because I think it is more descriptive than the Oracle outer join notation.
-
Inner join and 'PIVOT' results
Good day to all;
Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bi
PL/SQL Release 10.2.0.4.0 - Production
"CORE 10.2.0.4.0 Production."
AMT for Solaris: release 10.2.0.4.0 - Production
NLSRTL Version 10.2.0.4.0 - Production
I have 2 paintings I want to do a query on and then "pivot" results. I understand that, since it is 10 g using the PIVOT operator is not supported.
(Corrected code :)) issues
-Oops, measure twice cut once...create table CT ( DESIGN_ID NUMBER, CT_ID VARCHAR2(15) ) INSERT INTO CT VALUES ('654321','10QWER123456'); INSERT INTO CT VALUES ('987654','7ASDF654987'); INSERT INTO CT VALUES ('321654','82CHEV852963'); create table CXRF ( DESIGN_ID NUMBER, ROW_SEQ_NBR NUMBER, XREF_CT_ID VARCHAR2(15) ) INSERT INTO CXRF VALUES ('654321','1','25ABCD'); INSERT INTO CXRF VALUES ('654321','2','262ABCD'); INSERT INTO CXRF VALUES ('987654','1','14WXYZ'); INSERT INTO CXRF VALUES ('987654','2','34FRED'); INSERT INTO CXRF VALUES ('321654','1','1TOM');
Expected results would look like this:select design_id, ct_id, xref_ct_id from cxrf INNER JOIN ct on(ct.design_id = cxrf.design_id)
DESIGN_ID CT_ID XREF_CT_1 XREF_CT_2
Published by: GMoney on 9 may 2013 08:47
654321 10QWER123456 25ABCD 262ABCD
Published by: GMoney on 9 may 2013 08:49Thanks for posting examples of data and version, however, as said, it would be better if you can test, DDLS is full of typos.
Did you visit the FAQ before posting?
{message: id = 9360005}
There are also effective methods in previous versions of 11 g data pivot.
For example:SQL> select ct.design_id 2 , ct.ct_id 3 , min(case when cxrf.row_seq_nbr = 1 then cxrf.xref_ct_id end) as XREF_CT_1 4 , min(case when cxrf.row_seq_nbr = 2 then cxrf.xref_ct_id end) as XREF_CT_2 5 from cxrf 6 join ct on (ct.design_id = cxrf.design_id) 7 group by ct.design_id, ct.ct_id ; DESIGN_ID CT_ID XREF_CT_1 XREF_CT_2 ---------- ------------ ------------ ------------ 654321 10QWER123456 25ABCD 262ABCD 987654 7ASDF654987 14WXYZ 34FRED 321654 82CHEV852963 1TOM
-
How to do an INNER JOIN subquery?
Can't seem to find anything that could help out me with this.
My prototype query goes like this but its gives me an ORA-00905: lack of keyword
SELECT Poker_Site.site_name, bonus.sign_up_bonus
OF poker_site
INNER JOIN bonus
WHERE Poker_site.site_name = 'Poker Stars'
WE Poker_Site.site_name = bonus.site_name;Join INNER JOIN must be immediately followed by ONE and only then, where:
SELECT Poker_Site.site_name, bonus.sign_up_bonus FROM poker_site INNER JOIN bonus ON Poker_Site.site_name = bonus.site_name WHERE Poker_site.site_name = 'Poker Stars';
SY.
-
I would like to convert a subselect to use an inner join?
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0
I have the SQL below (it gives the correct data) using several sub selects I want to use in a PS query via the PS request handler. However, Manager queries PS will only a sub select when you create a query, but it will allow an inner join. So, I was hoping to rewrite it as a join but can not understand. Perhaps using a view would work? Or if it happens to be expert PS9.1 out there who might know an effcient way more to create the query that would be great as well. I have several versions of different trails of my SQL inner join if someone wishes to see those.
select business_unit, ledger, fund_code, account, foreign_amount, open_item_key from ps_open_item_gl a where (business_unit, ledger, fund_code, account) in (select business_unit, ledger, fund_code, account from (select business_unit, ledger, fund_code, account, sum(foreign_amount) from ps_open_item_gl b where b.open_item_status = 'O' group by business_unit, fund_code, account, ledger having sum(foreign_amount) = 0)) and open_item_status = 'O' and business_unit not in ('4110', '5301', '6501', '6602') order by 1, 2, 3, 4, 6
Hello
956171 wrote:
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0
I have the SQL below (it gives the correct data) using several sub selects I want to use in a PS query via the PS request handler. However, Manager queries PS will only a sub select when you create a query, but it will allow an inner join. So, I was hoping to rewrite it as a join but can not understand.I don't know what you mean by "select sub", or what exactly is the PS limitation.
Are you talking about the query nested in the IN clause? It is not necessary. The following is equivalent to what you posted:select business_unit, ledger, fund_code, account, foreign_amount, open_item_key from ps_open_item_gl a where (business_unit, ledger, fund_code, account) in ( select business_unit, ledger, fund_code, account from ps_open_item_gl b where b.open_item_status = 'O' and business_unit not in ('4110', '5301', '6501', '6602') group by business_unit, ledger, fund_code, account having sum (foreign_amount) = 0 ) and open_item_status = 'O' order by 1, 2, 3, 4, 6
I move the condition 'and business_unit not in ('4110', '5301', '6501', 6602') ' in the subquery just for efficiiency.
I think you would need a subquery, even if you don't re - he writes as a join.
Perhaps using a view would work?
No doubt. Again, I know not what PS objects to, but you can probably hide in a vision where the PS can complain about this.
-
inner join is not eliminating duplicates!
Name of the table is customers
VALUE CITY SIDE NUMS CNAME
1 2001 Hoffman 100 1001 London
2 Rome 2002 200 1003 Giovanni
3 2003 Liu San Jose 200 1002
4 2004 grass Berlin 300 1002
5 2006 Clemens 100 1001 London
6 2008 Cisneros San Jose 300 1007
7 2007 perish Rome 100 1004
Query is
To find all pairs of customers having the same side
I tried:
SELECT c.cname, cb.cname FROM customers c INNER JOIN customers cb WE cb.rating AND c.cname = c.rating! = cb.cname
CNAME CNAME
1 perish Hoffman
2 Clemens Hoffman
3 Liu Giovanni
4 Giovanni Liu
5 Cisneros grass
6 perira Clemens
7 Hoffman Clemens
8 grass Cisneros
Clemens 9 perish
10 Hoffman perish
Ideally, it should up to 5 rows, but it does not return these lines for an e.g. Hoffman perish since I'm Perira Hoffman already. Your answers will be appreciated.
Thank you
VaibhavHi, Vaibhav,
914683 wrote:
Name of the table is customersVALUE CITY SIDE NUMS CNAME
1 2001 Hoffman 100 1001 London
2 Rome 2002 200 1003 Giovanni
3 2003 Liu San Jose 200 1002
4 2004 grass Berlin 300 1002
5 2006 Clemens 100 1001 London
6 2008 Cisneros San Jose 300 1007
7 2007 perish Rome 100 1004Query is
To find all pairs of customers having the same sideI tried:
SELECT c.cname, cb.cname FROM customers c INNER JOIN customers cb WE cb.rating AND c.cname = c.rating! = cb.cname
Perhaps what you want is
SELECT c.cname , cb.cname FROM customers c INNER JOIN customers cb ON c.rating = cb.rating AND c.cname < cb.cname -- not != ;
CNAME CNAME
1 perish Hoffman
2 Clemens Hoffman
3 Liu Giovanni
4 Giovanni Liu
5 Cisneros grass
6 perira Clemens
7 Hoffman Clemens
8 grass Cisneros
Clemens 9 perish
10 Hoffman perishThe title you chose for this thread is "inner join is not eliminating duplicates!
Inner joins (or other types of joints) are not supposed to remove duplicates. Use SELECT DISTINCT to remove duplicates, which is exactly the same lines.
You don't have to duplicate. For example, these lines of your result set:` CNAME CNAME 1 Perira Hoffman 10 Hoffman Perira
are not identical; Indeed, the two columns are different.
Ideally, it should up to 5 rows, but it does not return these lines for an e.g. Hoffman perish since I'm Perira Hoffman already.
Please report the exact output of the sample data you want. (As said by Hoek, post CREATE TABLE and INSERT statements for the sample data too.)
-
The following query works fine as long as there is a value in the subID field, which is the end of the inner join statement. If the subID is empty then no data is output, even if it is there. Try as I may, I can't do the right solution in which the statement to get the data to show without the subID. What Miss me?
< name cfquery = "getInfo" datasource = "#application.database #" >
Select page_id, pageName, pages.content, pages.cat_id, pages.seo_title, pages.seo_desc, pages.seo_words, pages.h1_title, pages.pic, pages.brochure, pa ges.video, catagories.catagory, subcat.subID, subcat.sub_category
(page INNER JOIN categories ON pages.cat_id = catagories.cat_id) INNER JOIN subcat ON pages.subID = subcat.subID
where pages.page_id = #page_id #.
< / cfquery >
Rick,
Looks like you need a LEFT OUTER join to the table "subcat", so that all the records for the 'pages' and 'categories' are returned, even if no records matching "subcat" doesn't exist. Joins INTERNAL returns only the selected records when both sides of the join statement tables have matching values, while you will get a join OUTER LEFT (sometimes also known simply as a LEFT JOIN) * everything * selected records from the table on the left side of the join statement, no matter if he adapt records from the table on the right side of the join statement. When there is no corresponding record in the table on the right side of the join statement, all the columns in your SELECT clause that come from the table on the right side of the join statement will contain NULL values.
HTH,
-Carl V.
-
Hello
My update with the inner join does not seem to work.
UPDATE RECAP R SET R.FLAVOR = (SELECT FN. FLAVOR_NDC FN FLAVOR, REPLACE CAP R WHERE R.NDC11 = FN. NDC11)
When I write the query above, the inner circle question (SELECT FN. FLAVOR_NDC FN FLAVOR, REPLACE CAP R WHERE R.NDC11 = FN. NDC11) returns multiple lines, and it's a new syntax for me (as I was Teradata and SQL server).
Can you please how this request can be written to make it work?
I get the error message below
SQL error: ORA-01427: einreihig subquery returns multiple rows
01427 00000 - "einreihig subquery returns several lines.1. fix your code:
UPDATE RECAP R SET R.FLAVOR = (SELECT FN.FLAVOR FROM FLAVOR_NDC FN WHERE R.NDC11 = FN.NDC11)
2. you can use the fusion
merge into RECAP R using FLAVOR_NDC FN on(R.NDC11 = FN.NDC11) when matched then update set R.FLAVOR = FN.FLAVOR
Kind regards
Malakshinov Sayan -
Urgent help please. Inner join caused the error ora-00933
I ran it, works great:
SELECT DIFFERENT EXP. EXP_ID,
EXP. DATU_EXP_WIRE_CENTER_CLLI,
EXP. DATU_EXP_IP,
EXP. DATU_EXP_CLLI,
EXP. DATU_EXP_PORT,
EXP. DATU_EXP_NAME,
EXP. DATU_EXP_CITY,
EXP. DATU_EXP_STATE,
EXP. DATU_EXP_SW_VERSION,
DECODE (LAST_ALARM. LAST_ALARM_DATE, NULL, TO_CHAR (SYSDATE, ' YYYY/MM/DD HH24:MI:SS'),
TO_CHAR (LAST_ALARM. LAST_ALARM_DATE, "YYYY/MM/DD HH24:MI:SS")) AS STATUS_DATE,
DECODE (LAST_ALARM. ALARM_NAME, NULL, "disconnected", LAST_ALARM. ALARM_NAME) AS DATU_STATUS,
DECODE (LAST_ALARM. ALARM_CLASS, NULL, 'OTHER', LAST_ALARM. ALARM_CLASS) AS IS_ERROR_STATUS,
DECODE (LAST_RESOURCE. LAST_ALARM_DATE, NULL, ", TO_CHAR (LAST_RESOURCE. LAST_ALARM_DATE, "YYYY/MM/DD HH24:MI:SS")) AS RESOURCE_STATUS_DATE,
DECODE (LAST_RESOURCE. RESOURCE_CODE_NAME, NULL, ", LAST_RESOURCE. RESOURCE_CODE_NAME) AS RESOURCE_STATUS,
DECODE (LAST_RESOURCE. RESOURCE_CODE_CLASS, NULL, ", LAST_RESOURCE. RESOURCE_CODE_CLASS) AS IS_RESOURCE_ERROR_STATUS,
DECODE (LAST_OPER. LAST_ALARM_DATE, NULL, ", TO_CHAR (LAST_OPER. LAST_ALARM_DATE, "YYYY/MM/DD HH24:MI:SS")) AS OPER_STATUS_DATE,
DECODE (LAST_OPER. OPER_CODE_NAME, NULL, ", LAST_OPER. OPER_CODE_NAME) AS OPER_STATUS,
DECODE (LAST_OPER. OPER_CODE_CLASS, NULL, ", LAST_OPER. OPER_CODE_CLASS) AS IS_OPER_ERROR_STATUS,
EXP BEGIN_MAINT_WINDOW, RTU. RTU_NAME
OF TT_DATU_EXP_UNIT_INFO EXP
left outer join
(SELECT distinct alarmed_datus. EXP_ID, c.ALARM_NAME, c.ALARM_TYPE, c.ALARM_CLASS and alarmed_datus. LAST_ALARM_DATE
Of alarmed_datus (SELECT EXP_ID, MAX (ALARM_TIME) AS LAST_ALARM_DATE FROM TT_DATU_EXP_ALARM_INFO GROUP BY EXP_ID)
inner join TT_DATU_EXP_ALARM_INFO b on b.EXP_ID = alarmed_datus. EXP_ID AND b.ALARM_TIME = alarmed_datus. LAST_ALARM_DATE
inner join TT_DATU_EXP_ALARM_TYPES c on b.ALARM_TYPE = c.ALARM_TYPE
) LAST_ALARM on EXP.. EXP_ID = LAST_ALARM. EXP_ID
left outer join
(SELECT distinct a.EXP_ID, c.RESOURCE_CODE_NAME, c.RESOURCE_CODE_TYPE, c.RESOURCE_CODE_CLASS, a.LAST_ALARM_DATE
FROM (SELECT EXP_ID, MAX (RESOURCE_CODE_TIME) AS LAST_ALARM_DATE
OF TT_DATU_EXP_RESOURCE_CODE_INFO GROUP BY EXP_ID) a
inner join TT_DATU_EXP_RESOURCE_CODE_INFO b on b.EXP_ID = a.EXP_ID AND b.RESOURCE_CODE_TIME = a.LAST_ALARM_DATE
inner join TT_DATU_EXP_RESOURCECODE_TYPES c on b.RESOURCE_CODE_TYPE = c.RESOURCE_CODE_TYPE
) LAST_RESOURCE on EXP.. EXP_ID = LAST_RESOURCE. EXP_ID
left outer join
(SELECT distinct a.EXP_ID, c.OPER_CODE_NAME, c.OPER_CODE_TYPE, c.OPER_CODE_CLASS, a.LAST_ALARM_DATE
FROM (SELECT EXP_ID, MAX (OPER_CODE_TIME) AS LAST_ALARM_DATE
OF TT_DATU_EXP_OPER_CODE_INFO GROUP BY EXP_ID) a
inner join TT_DATU_EXP_OPER_CODE_INFO b on b.EXP_ID = a.EXP_ID AND b.OPER_CODE_TIME = a.LAST_ALARM_DATE
inner join TT_DATU_EXP_OPER_CODE_TYPES c on b.OPER_CODE_TYPE = c.OPER_CODE_TYPE) LAST_OPER on EXP.. EXP_ID = LAST_OPER. EXP_ID
inner join TT_DATU_LRN_MAP on exp. EXP_ID = NAB NAB. EXP_ID AND TRIM (NAB. LRN) AS p_LRN
inner join TT_RTU_TYPES on exp. RTU_TYPE_ID = RTU RTU. RTU_TYPE_ID
WHERE THERE IS NOT (SOME SATELLITE_EXP_ID OF TT_HOST_SATELLITE WHERE EXP. EXP_ID = SATELLITE_EXP_ID)
AND EXP.IS_PRIMARY_ADDRESS LIKE p_isPrimary;
ON THE OTHER
OPEN FOR V_cursor
SELECT EXP. EXP_ID,
EXP. DATU_EXP_WIRE_CENTER_CLLI,
EXP. DATU_EXP_IP,
EXP. DATU_EXP_CLLI,
EXP. DATU_EXP_PORT,
EXP. DATU_EXP_NAME,
EXP. DATU_EXP_CITY,
EXP. DATU_EXP_STATE,
EXP. DATU_EXP_SW_VERSION,
DECODE (LAST_ALARM. LAST_ALARM_DATE, NULL, TO_CHAR (SYSDATE, ' YYYY/MM/DD HH24:MI:SS'), TO_CHAR (LAST_ALARM. LAST_ALARM_DATE, "YYYY/MM/DD HH24:MI:SS")) AS STATUS_DATE,
DECODE (LAST_ALARM. ALARM_NAME, NULL, "disconnected", LAST_ALARM. ALARM_NAME) AS DATU_STATUS,
DECODE (LAST_ALARM. ALARM_CLASS, NULL, 'OTHER', LAST_ALARM. ALARM_CLASS) AS IS_ERROR_STATUS,
DECODE (LAST_RESOURCE. LAST_ALARM_DATE, NULL, ", TO_CHAR (LAST_RESOURCE. LAST_ALARM_DATE, "YYYY/MM/DD HH24:MI:SS")) AS RESOURCE_STATUS_DATE,
DECODE (LAST_RESOURCE. RESOURCE_CODE_NAME, NULL, ", LAST_RESOURCE. RESOURCE_CODE_NAME) AS RESOURCE_STATUS,
DECODE (LAST_RESOURCE. RESOURCE_CODE_CLASS, NULL, ", LAST_RESOURCE. RESOURCE_CODE_CLASS) AS IS_RESOURCE_ERROR_STATUS,
DECODE (LAST_OPER. LAST_ALARM_DATE, NULL, ", TO_CHAR (LAST_OPER. LAST_ALARM_DATE, "YYYY/MM/DD HH24:MI:SS")) AS OPER_STATUS_DATE,
DECODE (LAST_OPER. OPER_CODE_NAME, NULL, ", LAST_OPER. OPER_CODE_NAME) AS OPER_STATUS,
DECODE (LAST_OPER. OPER_CODE_CLASS, NULL, ", LAST_OPER. OPER_CODE_CLASS) AS IS_OPER_ERROR_STATUS,
EXP BEGIN_MAINT_WINDOW, RTU. RTU_NAME
OF TT_DATU_EXP_UNIT_INFO EXP
(in left outer join
SELECT distinct alarmed_datus. EXP_ID, c.ALARM_NAME, c.ALARM_TYPE, c.ALARM_CLASS and alarmed_datus. LAST_ALARM_DATE
Of alarmed_datus (SELECT EXP_ID, MAX (ALARM_TIME) AS LAST_ALARM_DATE FROM TT_DATU_EXP_ALARM_INFO GROUP BY EXP_ID)
inner join TT_DATU_EXP_ALARM_INFO b on b.EXP_ID = alarmed_datus. EXP_ID AND b.ALARM_TIME = alarmed_datus. LAST_ALARM_DATE
inner join TT_DATU_EXP_ALARM_TYPES c on b.ALARM_TYPE = c.ALARM_TYPE)
LAST_ALARM on EXP.. EXP_ID = LAST_ALARM. EXP_ID
left outer join
(SELECT distinct a.EXP_ID, c.RESOURCE_CODE_NAME, c.RESOURCE_CODE_TYPE, c.RESOURCE_CODE_CLASS, a.LAST_ALARM_DATE
FROM (SELECT EXP_ID, MAX (RESOURCE_CODE_TIME) AS LAST_ALARM_DATE
OF TT_DATU_EXP_RESOURCE_CODE_INFO GROUP BY EXP_ID) a
inner join TT_DATU_EXP_RESOURCE_CODE_INFO b on b.EXP_ID = a.EXP_ID AND b.RESOURCE_CODE_TIME = a.LAST_ALARM_DATE
inner join TT_DATU_EXP_RESOURCECODE_TYPES c on b.RESOURCE_CODE_TYPE = c.RESOURCE_CODE_TYPE) LAST_RESOURCE on EXP.. EXP_ID = LAST_RESOURCE. EXP_ID
left outer join
(SELECT distinct a.EXP_ID, c.OPER_CODE_NAME, c.OPER_CODE_TYPE, c.OPER_CODE_CLASS, a.LAST_ALARM_DATE
FROM (SELECT EXP_ID, MAX (OPER_CODE_TIME) AS LAST_ALARM_DATE
OF TT_DATU_EXP_OPER_CODE_INFO GROUP BY EXP_ID) a
inner join TT_DATU_EXP_OPER_CODE_INFO b on b.EXP_ID = a.EXP_ID AND b.OPER_CODE_TIME = a.LAST_ALARM_DATE
inner join TT_DATU_EXP_OPER_CODE_TYPES c on b.OPER_CODE_TYPE = c.OPER_CODE_TYPE
) LAST_OPER on EXP.. EXP_ID = LAST_OPER. EXP_ID ORDER BY EXP. DATU_EXP_CLLI
inner join TT_RTU_TYPES on exp. RTU_TYPE_ID = RTU RTU. RTU_TYPE_ID
WHERE THERE is NOT (SOME SATELLITE_EXP_ID OF TT_HOST_SATELLITE WHERE EXP.. EXP_ID = SATELLITE_EXP_ID) AND EXP.IS_PRIMARY_ADDRESS love
p_isPrimary;
However this one:
SELECT EXP. EXP_ID,
EXP. DATU_EXP_WIRE_CENTER_CLLI,
EXP. DATU_EXP_IP,
EXP. DATU_EXP_CLLI,
EXP. DATU_EXP_PORT,
EXP. DATU_EXP_NAME,
EXP. DATU_EXP_CITY,
EXP. DATU_EXP_STATE,
EXP. DATU_EXP_SW_VERSION,
DECODE (LAST_ALARM. LAST_ALARM_DATE, NULL, TO_CHAR (SYSDATE, ' YYYY/MM/DD HH24:MI:SS'),
TO_CHAR (LAST_ALARM. LAST_ALARM_DATE, "YYYY/MM/DD HH24:MI:SS")) AS STATUS_DATE,
DECODE (LAST_ALARM. ALARM_NAME, NULL, "disconnected", LAST_ALARM. ALARM_NAME) AS DATU_STATUS,
DECODE (LAST_ALARM. ALARM_CLASS, NULL, 'OTHER', LAST_ALARM. ALARM_CLASS) AS IS_ERROR_STATUS,
DECODE (LAST_RESOURCE. LAST_ALARM_DATE, NULL, ", TO_CHAR (LAST_RESOURCE. LAST_ALARM_DATE, "YYYY/MM/DD HH24:MI:SS")) AS RESOURCE_STATUS_DATE,
DECODE (LAST_RESOURCE. RESOURCE_CODE_NAME, NULL, ", LAST_RESOURCE. RESOURCE_CODE_NAME) AS RESOURCE_STATUS,
DECODE (LAST_RESOURCE. RESOURCE_CODE_CLASS, NULL, ", LAST_RESOURCE. RESOURCE_CODE_CLASS) AS IS_RESOURCE_ERROR_STATUS,
DECODE (LAST_OPER. LAST_ALARM_DATE, NULL, ", TO_CHAR (LAST_OPER. LAST_ALARM_DATE, "YYYY/MM/DD HH24:MI:SS")) AS OPER_STATUS_DATE,
DECODE (LAST_OPER. OPER_CODE_NAME, NULL, ", LAST_OPER. OPER_CODE_NAME) AS OPER_STATUS,
DECODE (LAST_OPER. OPER_CODE_CLASS, NULL, ", LAST_OPER. OPER_CODE_CLASS) AS IS_OPER_ERROR_STATUS,
EXP BEGIN_MAINT_WINDOW, RTU. RTU_NAME
OF TT_DATU_EXP_UNIT_INFO EXP
left outer join
(
SELECT distinct alarmed_datus. EXP_ID, c.ALARM_NAME, c.ALARM_TYPE, c.ALARM_CLASS and alarmed_datus. LAST_ALARM_DATE
Of alarmed_datus (SELECT EXP_ID, MAX (ALARM_TIME) AS LAST_ALARM_DATE FROM TT_DATU_EXP_ALARM_INFO GROUP BY EXP_ID)
inner join TT_DATU_EXP_ALARM_INFO b on b.EXP_ID = alarmed_datus. EXP_ID AND b.ALARM_TIME = alarmed_datus. LAST_ALARM_DATE
inner join TT_DATU_EXP_ALARM_TYPES c on b.ALARM_TYPE = c.ALARM_TYPE) LAST_ALARM on EXP.. EXP_ID = LAST_ALARM. EXP_ID
left outer join
(SELECT distinct a.EXP_ID, c.RESOURCE_CODE_NAME, c.RESOURCE_CODE_TYPE, c.RESOURCE_CODE_CLASS, a.LAST_ALARM_DATE
FROM (SELECT EXP_ID, MAX (RESOURCE_CODE_TIME) AS LAST_ALARM_DATE
OF TT_DATU_EXP_RESOURCE_CODE_INFO GROUP BY EXP_ID) a
inner join TT_DATU_EXP_RESOURCE_CODE_INFO b on b.EXP_ID = a.EXP_ID AND b.RESOURCE_CODE_TIME = a.LAST_ALARM_DATE
inner join TT_DATU_EXP_RESOURCECODE_TYPES c on b.RESOURCE_CODE_TYPE = c.RESOURCE_CODE_TYPE) LAST_RESOURCE on EXP.. EXP_ID = LAST_RESOURCE. EXP_ID
left outer join
(SELECT distinct a.EXP_ID, c.OPER_CODE_NAME, c.OPER_CODE_TYPE, c.OPER_CODE_CLASS, a.LAST_ALARM_DATE
FROM (SELECT EXP_ID, MAX (OPER_CODE_TIME) AS LAST_ALARM_DATE
OF TT_DATU_EXP_OPER_CODE_INFO GROUP BY EXP_ID) a
inner join TT_DATU_EXP_OPER_CODE_INFO b on b.EXP_ID = a.EXP_ID AND b.OPER_CODE_TIME = a.LAST_ALARM_DATE
inner join TT_DATU_EXP_OPER_CODE_TYPES c on b.OPER_CODE_TYPE = c.OPER_CODE_TYPE
) LAST_OPER on EXP.. EXP_ID = LAST_OPER. EXP_ID ORDER BY EXP. DATU_EXP_CLLI
inner join TT_RTU_TYPES on exp. RTU_TYPE_ID = RTU RTU. RTU_TYPE_ID
WHERE the EXP.IS_PRIMARY_ADDRESS as p_isPrimary;
It does not work kept send me errors:
[ORA-00933: SQL not correctly completed command]
Any guru can help? I need to have this resolved effect today.
Thanks in advance.
Maybe you are looking for
-
Gel to the import screen?
Hi all. Me once again. Currently, I am trying to import images and FCPX freezes on the import screen, then I have to force quit and open it again, only so he can freeze once more when I try to import images. The program itself seems to work fine, asi
-
I have an eco I can't get rid of on my presario cq56-112SA (windows 7)
I just plugged my headphones and then when I got out once again, he has now got an ego. If you help or advice that would solve my problem would be great Thank you
-
2FIP % Ethernet NOR communication Allen Bradley
I want to communicate to the Allen Bradley plc cRIO (specifically ControlLogix L72, L73 or L725) via Ethernet/IP. I am a beginner so I don't know exactly how to proceed. I downloaded the Ethernet/ip driver of OR. I just want to talk to one of the co
-
After the removal of some components of Windows, I lost some features on my XP computer
I recently tried to fix errors after upgrading to Windows Live, including the removal of some components of Windows (oops)! Now I can't use Internet Explorer, I don't have a calculator or the original games... I tried to restore the system to an ea
-
Hello.. Please please please give me a solution... I have a bb torch 9800... I received a msg to upgrade global app... after the upgrade... I can not find the global icon... Although it is installed on my phone... the icon is not the case to find. I