Need for outer join
Hi gurus
Need your advice once again.
I have following script.
Table creation and Insertion.
drop table full_data;
drop table not_full_data;
create the table full_data
(
GRP varchar2 (10)
)
;
insert into full_data
(
Select '100' across double Union
Select '200' of any double union
Select '300' of the double
);
create the table not_full_data
(
GRP varchar2 (10),
cvg_code varchar2 (10),
line_type varchar2 (1)
);
insert into not_full_data
(
Select '100', '0', 'L' from dual
Union of all the
Select '200', '20130801', 'L' from dual
);
Select * from not_full_data has.
full_data b
where = b.grp a.grp (+)
and line_type (+) = 'L '.
and (cvg_code (+) = '0'
or cvg_code > = '20120101')
;
I'm putting the outer join to get all rows in full_data but when I try to put the outer join, then oracle does not allow me to put it and gives me below error:
Error
ORA-01719: outer join operator not allowed in operand of GOLD or IN
01719 00000 - "outer join operator not allowed in GOLD or IN the operand.
* Cause: Outer join appears in a clause or.
* Action: If A and B are predicates, to achieve the effect of (has or B).
Try (where select them (a and not B)) Union all the (where select them (B)).
Error on line: column 33: 17
I do not want to use full join and need this using the outer join. Thanks in advance
Concerning
Shu
This is the required query
SELECT *.
Not_full_data a, full_data b
WHERE a.grp (+) = b.grp
AND line_type (+) = 'L '.
AND (cvg_code = '0' OR cvg_code > = '20120101' OR cvg_code is NULL)
Tags: Database
Similar Questions
-
Hi all
Oracle Version: 11.2.0.2.0
with tab1 as
(
Select 1 model_id 10 dealer_id 10 price null of double net_price
Union all the
Select 2 model_id 10 dealer_id 12 price null of double net_price
Union all the
Select 3 model_id 10 dealer_id 11 price of double
Union all the
Select 3 model_id 20 dealer_id 12 price of double
)
Select * de tab1
with tab2 as
(
Select 10 dealer_id , 4 discount of double
Union all the
Select 20 dealer_id , 5 discount of double
Union all the
Select 30 dealer_id , 5 discount of double
Union all the
Select 40 dealer_id 10 discount of double
)
Select * de tab2
with Master_table as
(
Select 1 model_id 10 dealer_id of double
Union all the
Select 2 model_id 20 dealer_id of double
Union all the
Select 2 model_id 10 dealer_id of double
Union all the
Select 5 model_id 20 dealer_id of double
Union all the
Select 3 model_id 10 dealer_id of double
Union all the
Select 1 model_id 30 dealer_id of double
Union all the
Select 2 model_id 40 dealer_id of double
)
Select * de master_table
I have to calculate the net price which is = price - discount.
For the combination model/dealer (from the main table) for which is there is no record in tab1 should be filled with the value NULL.
Please find output as below
The model ID
Dealer_id
Price
Net price
1
10
10
6
2
10
12
8
3
10
12
7
3
20
12
8
4
20
5
20
1
30
2
40
Hello
Try this query,
Select model_id, dealer_id, net_price price-discount price
(
Select b.discount, a.model_id, a.dealer_id, b.price of
master_table one
left outer join
(select a.model_id, a.dealer_id, b.discount from tab1 a.price an outer join tab2 b on a.dealer_id = b.dealer_id left) b
on a.model_id = b.model_id and a.dealer_id = b.dealer_id
)
out put will be
MODEL_ID DEALER_ID PRICE NET_PRICE
--------- --------- --------- ---------
3 10 11 7
2 10 12 8
1 10 10 6
2 20
1 30
2 40
5 207 selected lines.
-
Hi Experts,
I have a requirement that says - see the chart for the past 10 days, regardless the presence data table in fact.
Lets consider an example - Time_dim product, are my dimension tables, Purchase_Order is my fact table.I did it for external Purchase_Order in left RPD with TIME_DIM and inner join with the PRODUCT table. and execution of query of exit-
Select T.Date, P.item, count (distinct PO.order_no)
TIME_DIM t, PRODUCT P, PURCHASE_ORDER PO
where T.date_key = PO.date_key
and P.item = in. agenda
and P.item = 'laptop ';The query generated by OBIEE left outer join, but when the condition P.item = "Notebook" included in the query, and if there are no orders for this product in one of the date, that date will not come in the result set.
the query to be generated by the OBIEE is-
Select T.Date, PO.item, count (distinct PO.order_no)
TIME_DIM t,.
(SELECT P.ITEM, IN. ORDER_NO
PRODUCT P, PO PURCHASE_ORDER
WHERE P.item = in. agenda
and P.item = 'Laptop') IN.
WHERE T.date_key = PO.date_key (+);How to design the RPD to achieve this. All pray to advise on this. Thanks in advance.
Thank you
ChantalHello
You are on 11.1.1.7?
I would say that your condition can be made without using external and maintenance of product and the standard between the FACT dimension, time inner join join.
If you enable your property analysis OBIEE "Include Null values" will automatically return all the elements of time and product matching your filter (so you'll need to add a filter on 'Date' to limit it to the last 10 days or you will have a unique day of your time dimension).
If you filter then on "Laptop", even if there is not a single value in order for "Laptop" in the last 10 days, he will be there on the screen.
Easy, clean and you keep your inner join between the facts and Dimensions.
Take a look at this example, I just did on SampleApp 406:
Selection of 12 months (year 2010) and a customer (id = 89) and income. The model has only an inner join. I activate the option "Include Null values" and here is the result.
A line with cells only empty because there is not a single revenue for customer 89 in 2010. This is exactly your condition.
Honestly, do not touch your model using the outer join, you will have more side effects than benefits. Every single scan will do the outer join and you'll have a lot of data 'empty' return of the DB (more large data set containing just the null values) and probably you need the outer join in 15 to 25% of your analysis.
Keep things simple, it will be faster and easier to maintain.
-
Create a view which limits a large table, but also allows an outer join?
Oracle 10.2.0.4
CREATE TABLE MY_PAY_ITEMS
(EMP VARCHAR2 (8) NOT NULL)
, PAY_PRD VARCHAR2 (8) NOT NULL
, KEY1 VARCHAR2 (8) NOT NULL
, KEY2 VARCHAR2 (8) NOT NULL
, LN_ITEM VARCHAR2 (4) NOT NULL
, ITEM_AMT NUMBER (24.2) NOT NULL
VARCHAR2 (100) FILL NON-NULL)
INSERT INTO MY_PAY_ITEMS
SELECT A.EMP
B.PAY_PRD
C.KEY1
D.KEY2
E.LN_ITEM
F.ITEM_AMT
, ' '
FROM (SELECT TO_CHAR (ROWNUM, ' 00000000') 'EMP' FROM DUAL CONNECT BY LEVEL < = 50) has
, (SELECT '2010-' |) To_char(rowNum,'00') 'PAY_PRD' FROM DUAL CONNECT BY LEVEL < = 52) B
, (SELECT TO_CHAR (ROWNUM, ' 000') 'KEY1' FROM DUAL CONNECT BY LEVEL < = 8) C
, (SELECT TO_CHAR (ROWNUM, ' 000') 'Key2' FROM DUAL CONNECT BY LEVEL < = 5) D
, (SELECT TO_CHAR(ROWNUM,'000') 'LN_ITEM' FROM DUAL CONNECT BY LEVEL < = 20) E
(round (DBMS_RANDOM. VALUE * 400.2) "ITEM_AMT" of the double) F
CREATE A UNIQUE INDEX MY_PAY_ITEMS ON MY_PAY_ITEMS (MEP, PAY_PRD, KEY1, KEY2, LN_ITEM)
CREATE TABLE MY_ITEM_DISPLAY
(THE VARCHAR2 (4) OF DISPLAY_CODE NOT NULL)
, NUMBER (2) SEQUENCE NON-NULL
, COLUMN_ITEM1 VARCHAR2 (4) not null
, COLUMN_ITEM2 VARCHAR2 (4) not null
, COLUMN_ITEM3 VARCHAR2 (4) not null
COLUMN_ITEM4 VARCHAR2 (4) not null)
INSERT INTO MY_ITEM_DISPLAY VALUES ('01 ', 10, '001', '003', '004',' 005');
INSERT INTO MY_ITEM_DISPLAY VALUES ('01 ', 20 '007', '013', '004',' 009');
INSERT INTO MY_ITEM_DISPLAY VALUES ('01', 30 ' 001', '004', '009',' 011');
INSERT INTO MY_ITEM_DISPLAY VALUES ('01', 40, '801 ', ' 304 ', 209',' 111');
INSERT INTO MY_ITEM_DISPLAY VALUES ('02 ', 10, '001', '003', '004',' 005');
INSERT INTO MY_ITEM_DISPLAY VALUES ('02 ', 20 '007', '013', '004',' 009');
INSERT INTO MY_ITEM_DISPLAY VALUES ('02', 30 ' 001', '004', '009',' 011');
MY_PAY_ITEMS is a table that stores line of payslip items. It has a total area of 500,000,000 lines.
PEM is the unique id, we have about 200,000 employees (with about 50,000 being active today).
PAY_PRD is a weekly pointer (2010-01, 2010-02, 2010-52), we have the 2004 data and add a new pay period each week. 2010 01 is defined as the first Monday in 2010 for the first Sunday in 2010, etc.
Key1 is an internal key, it follows the chronology in the pay period.
KEY2 is a child of KEY1, there follows the sequence of events in KEY1.
LN_ITEM is the component of actual compensation resulting from the event, on average, a person produces 20 lines per event. Note that in this example, everyone gets the same LN_ITEM values, but in practice it is selected 20 of 300
ITEM_AMT is the net salary per command line.
FILLING is a set of fields that are unrelated to this issue, but act as a brake on the charges of the line.
MY_ITEM_DISPLAY is an array that describes how some screens should display items. The screen itself is a grid of 4 poles, with the content of each cell is defined as a LN_ITEMS search to retrieve the relevant LN_AMT.
We have an application that receives a DISPLAY_CODE and an EMP. It automatically creates an sql statement in the sense of
SELECT * FROM MY_VIEW WHERE DISPLAY_CODE =: 1 AND EMP =: 2
and returns the output to the user.
My challenge is that I need to rewrite MY_VIEW as follows:
(1) (select the relevant lines from MY_ITEM_DISPLAY where DISPLAY_CODE =: 1)
(2) select the relevant all MY_PAY_ITEMS lines that meet the criteria
(a) EMP =: 2
(b) PAY_PRD = (a more recent for EMP and sysdate, so if he got last paid 2010-04, return 2010-04)
(c) KEY1 = (highest key1 in EMP and PAY_PRD)
(d) KEY2 = (highest key2 in KEY1, PAY_PRD and EMP)
(3) I then need to cross reference to create tabular output
(4) Finally, I have to return a 0 line where there is no LN_ITEMs (DISPLAY_CODE 01, 40 sequence contains possible values for this scenario)
The following query is part of it (but not the PAY_PRD, KEY1, KEy2)
Select * from)
SELECT A.DISPLAY_CODE
B.EMP
A.SEQUENCE
, MAX (DECODE (B.LN_ITEM, A.COLUMN_ITEM1, B.ITEM_AMT, 0)) 'COL1 '.
, MAX (DECODE (B.LN_ITEM, A.COLUMN_ITEM2, B.ITEM_AMT, 0)) 'COL2 '.
, MAX (DECODE (B.LN_ITEM, A.COLUMN_ITEM3, B.ITEM_AMT, 0)) 'COL3 '.
, MAX (DECODE (B.LN_ITEM, A.COLUMN_ITEM4, B.ITEM_AMT, 0)) 'COL4 '.
OF MY_ITEM_DISPLAY A, MY_PAY_ITEMS B
WHERE B.PAY_PRD = ' 2010-03'
GROUP OF A.DISPLAY_CODE, B.EMP, A.SEQUENCE)
WHERE DISPLAY_CODE = '01'
AND EMP = '0000011'
SEQUENCE ORDER
My questions
(1) how I do PAY_PRD, KEY1, KEY2 forced, can I use a form any of ROW_NUMBER() FUNCTION?
(2) how can I deal with the fact that none of the 4 LN_ITEMS column can exist (see sequence 40, none of these can exist)... Ideally the SQL above should return
01, 0000011, 10, < a digit - > < number > - < a digit - > < some number >
01, 0000011, 20, < a digit - > < number > - < a digit - > < some number >
01, 0000011, 30, < a number--> < number > - < number > - < number > -
01, 0000011, 40, 0, 0, 0, 0
I tried a UNION, but it prevented the view to eliminate most of the MY_PAY_ITEMS lines, because it solves ALL MY_PAY_ITEMS instead of simply retrieve lines for the EMP passed to the view. The same seems to be true for outer joins.
Hi Paula,
It does not handle SEQNUM 40, it's just that your second set of test data did not SEQNUM 40. When I put in the first set of values MY_ITEM_DISPLAY, I get:
DISP EMP SEQUENCE COL1 COL2 COL3 COL4
---- -------- ---------- ---------- ---------- ---------- ----------
01 00000011 10 101.1 103.1 105.1 104.1
01 00000011 20 107.1 113.1 104.1 109,1
01 00000011 30 101.1 104.1 109.1 99.99
01 00000011 40 0 0 0 0
If this isn't the issue, you will need to explain the requirement of "outer join" and what you want more. Apart from his return nothing if there is absolutely no element of remuneration of the employee, this query will always return a line for each line MY_ITEM_DISPLAY for the display_code. If there is absolutely no data, no return line seems reasonable.
-
What is the Assembly of 4 or 5 tables FULL OUTER JOIN logic?
the query is as below:
as you can see, I need FULL OUTER JOIN, these 5 tables and get a column from each table that is based on three common columns (ORG_iD, CUST_ID, CURRENT_DT).
And I wonder what is the logic of the 5 FULL OUTER JOIN table?
It will return if there is a folder that exists in the single table COL1? or table, COL2 and COL3 and so on. Basically any combination of these 5 tables.
Any ideas?SELECT (CASE WHEN COL1.ORG_ID IS NOT NULL THEN COL1.ORG_ID WHEN COL2.ORG_ID IS NOT NULL THEN COL2.ORG_ID WHEN COL3.ORG_ID IS NOT NULL THEN COL3.ORG_ID WHEN COL4.ORG_ID IS NOT NULL THEN COL4.ORG_ID ELSE COL5.ORG_ID END) ORG_ID, (CASE WHEN COL1.CUST_ID IS NOT NULL THEN COL1.CUST_ID WHEN COL2.CUST_ID IS NOT NULL THEN COL2.CUST_ID WHEN COL3.CUST_ID IS NOT NULL THEN COL3.CUST_ID WHEN COL4.CUST_ID IS NOT NULL THEN COL4.CUST_ID ELSE COL5.CUST_ID END) CUST_ID, (CASE WHEN COL1.CURRENT_DT IS NOT NULL THEN COL1.CURRENT_DT WHEN COL2.CURRENT_DT IS NOT NULL THEN COL2.CURRENT_DT WHEN COL3.CURRENT_DT IS NOT NULL THEN COL3.CURRENT_DT WHEN COL4.CURRENT_DT IS NOT NULL THEN COL4.CURRENT_DT ELSE COL5.CURRENT_DT END) CURRENT_DT, 'VENDORS' as ITEM_NAME, V_AGE_IND as ACCT_AGE_IND, COL1.AMT_ZSHT, COL2.AMT_YFYS, COL3.AMT_YFYS, COL4.AMT_YFYS, COL5.AMT_BZL, 'NAV', sysdate FROM COL1 FULL OUTER JOIN COL2 ON (COL1.ORG_ID=COL2.ORG_ID AND COL1.CURRENT_DT=COL2.CURRENT_DT AND COL1.CUST_ID=COL2.CUST_ID) FULL OUTER JOIN COL3 ON (COL2.ORG_ID=COL3.ORG_ID AND COL2.CURRENT_DT=COL3.CURRENT_DT AND COL2.CUST_ID=COL3.CUST_ID) FULL OUTER JOIN COL4 ON (COL3.ORG_ID=COL4.ORG_ID AND COL3.CURRENT_DT=COL4.CURRENT_DT AND COL3.CUST_ID=COL4.CUST_ID) FULL OUTER JOIN COL5 ON (COL4.ORG_ID=COL5.ORG_ID AND COL4.CURRENT_DT=COL5.CURRENT_DT AND COL4.CUST_ID=COL5.CUST_ID)
Thank youHello
When you perform a JOIN EXTERNAL COMPLETE multi - build that way, whenever you add a new table, you can just join the previous table because this table could be all NULL values for a given row. You can reach each new table to the first table, either, for the same reason. You must enclose each new table with all previous tables, like this:
FULL OUTER JOIN COL2 ON COL2.ORG_ID = COL1.ORG_ID AND COL2.CURRENT_DT = COL1.CURRENT_DT AND COL2.CUST_ID = COL1.CUST_ID FULL OUTER JOIN COL3 ON COL3.ORG_ID = COLAESCE (COL1.ORG_ID, COL2.ORG_ID) AND COL3.CURRENT_DT = COALESCE (COL1.CURRENT_DT, COL2.CURRENT_DT) AND COL3.CUST_ID = COALESCE (COL1.CUST_ID, COL2.CUST_ID) FULL OUTER JOIN COL3 ON COL4.ORG_ID = COLAESCE (COL1.ORG_ID, COL2.ORG_ID, COL3.ORG_ID) AND COL4.CURRENT_DT = COALESCE (COL1.CURRENT_DT, COL2.CURRENT_DT, COL3.CURRENT_DT) AND COL4.CUST_ID = COALESCE (COL1.CUST_ID, COL2.CUST_ID, COL3.CUST_ID) FULL OUTER JOIN COL3 ON COL5.ORG_ID = COLAESCE (COL1.ORG_ID, COL2.ORG_ID, COL3.ORG_ID, COL4.ORG_ID) AND COL5.CURRENT_DT = COALESCE (COL1.CURRENT_DT, COL2.CURRENT_DT, COL3.CURRENT_DT, COL4.CURRENT_DT) AND COL5.CUST_ID = COALESCE (COL1.CUST_ID, COL2.CUST_ID, COL3.CUST_ID, COL4.CUST_ID)
I hope that answers your question.
If not, post a small example data (CREATE TABLE and only relevant columns, INSERT statements), and the results you want from this data.
Explain how you get these results from these data.
Always tell what version of Oracle you are using. -
Hi all
I have a question where I need two outer join tables and there are a few filters based on the input parameters. In my example below, I need to know the difference between query 1 and 2. Query 1 does not have the data, but the fact of application 2. Please provide details
CREATE TABLE test1 ( col1 NUMBER(10), col2 VARCHAR2(10) ); INSERT INTO test1 VALUES(1,'Demo'); CREATE TABLE test2 ( col1 NUMBER(10), col2 VARCHAR2(10) ); INSERT INTO test2 VALUES(2,'Demo2'); --Query 1 SELECT * FROM test1,test2 WHERE test1.col1 = 1 AND test2.col1(+) = 3; --Query 2 SELECT * FROM test1,test2 WHERE test1.col1 = 1 AND test2.col1(+) = 3 AND test1.col1 = test2.col1(+);
In your first query, you make a Cartesian (but with a weird syntax) product with a table with no line.
If the result is nothing.In the second query you added a join condition and do a left outer join.
If the result contains the rows in the left table.
As you can see by simply adding a predicate with not enough to define a join.
ANSI JOIN syntax would be that this is possible.
-
Problem with XMLTABLE and LEFT OUTER JOIN
Hi all.
I have a problem with XMLTABLE and LEFT OUTER JOIN, in 11g it returns the correct result, but in 10g it doesn't, it is illustrated as a INNER JOIN.
This is all nice, now the problem:SELECT * FROM v$version; Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production PL/SQL Release 11.2.0.1.0 - Production "CORE 11.2.0.1.0 Production" TNS for Linux: Version 11.2.0.1.0 - Production NLSRTL Version 11.2.0.1.0 - Production --test for 11g CREATE TABLE XML_TEST( ID NUMBER(2,0), XML XMLTYPE ); INSERT INTO XML_TEST VALUES ( 1, XMLTYPE (' <msg> <data> <fields> <id>g1</id> <dat>data1</dat> </fields> </data> </msg> ') ); INSERT INTO XML_TEST VALUES ( 2, XMLTYPE (' <msg> <data> <fields> <id>g2</id> <dat>data2</dat> </fields> </data> </msg> ') ); INSERT INTO XML_TEST VALUES ( 3, XMLTYPE (' <msg> <data> <fields> <id>g3</id> <dat>data3</dat> </fields> <fields> <id>g4</id> <dat>data4</dat> </fields> <fields> <dat>data5</dat> </fields> </data> </msg> ') ); SELECT t.id, x.dat, y.seqno, y.id_real FROM xml_test t, XMLTABLE ( '/msg/data/fields' passing t.xml columns dat VARCHAR2(10) path 'dat', id XMLTYPE path 'id' )x LEFT OUTER JOIN XMLTABLE ( 'id' passing x.id columns seqno FOR ORDINALITY, id_real VARCHAR2(30) PATH '.' )y ON 1=1 ; ID DAT SEQNO ID_REAL -- ----- ----- ------- 1 data1 1 g1 2 data2 1 g2 3 data3 1 g3 3 data4 1 g4 3 data5
As you can see in 10g that I don't have the last row, it seems that Oracle 10 g does not recognize the LEFT OUTER JOIN.Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - 64bi PL/SQL Release 10.2.0.1.0 - Production "CORE 10.2.0.1.0 Production" TNS for HPUX: Version 10.2.0.1.0 - Production NLSRTL Version 10.2.0.1.0 - Production --exactly the same environment as 11g (tables and rows) SELECT t.id, x.dat, y.seqno, y.id_real FROM xml_test t, XMLTABLE ( '/msg/data/fields' passing t.xml columns dat VARCHAR2(10) path 'dat', id XMLTYPE path 'id' )x LEFT OUTER JOIN XMLTABLE ( 'id' passing x.id columns seqno FOR ORDINALITY, id_real VARCHAR2(30) PATH '.' )y ON 1=1 ; ID DAT SEQNO ID_REAL -- ----- ----- ------- 1 data1 1 g1 2 data2 1 g2 3 data3 1 g3 3 data4 1 g4
Is this a bug?, Metalink says that sometimes we can have an ORA-0600, but in this case there is no error results returned, just incorrect.
Help, please.
Kind regards.What about try the original Oracle method for outer joins? Using (+) without the extra space
XMLTABLE(...COLUMNS ... id XMLTYPE PATH ... ) x, XMLTABLE(... PASSING x.id ...) (+) y
-
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.
-
need help for an outer join query
Hi friends...
I have oracle 10g...
I have a question which involve is joining three tables...
the query is as follows:
in my front end application has some delete operations that removes specific data of the IPOADM_BATCH. MKT_SPEC_UV1 due to which the above query is nor fetch all rows.SELECT DISTINCT MU.MKT_ID "PAR ID", MU.MKT_ID "ROOT ID", MSU.SPEC_ID "ID", SU.SPEC_DESC "DESC", SU.SPEC_CD "SPEC CD" FROM IPOADM_BATCH.MKT_UV1 MU, IPOADM_BATCH.MKT_SPEC_UV1 MSU, IPOADM_BATCH.SPEC_UV1 SU WHERE MSU.MKT_ID = MU.MKT_ID AND MSU.SPEC_ID = SU.SPEC_ID AND SU.SPEC_GRP_OR_CMPSTN_CD = 'C';
the relationship between the tables is clearly from the above query...
I have the data in IPOADM_BATCH. MKT_UV1 and IPOADM_BATCH. Table of SPEC_UV1 after the delete operation
now, I want the query above to retrieve data from IPOADM_BATCH. MKT_UV1 with small changes to the above query even if there is no data in IPOADM_BATCH. MKT_SPEC_UV1.
I thought that if I use an outer join I can get it, but here I have to join three tables-join condition is based on the table that doesn't have a data...
so please help me guys how can I change the query to get my desired out put...Hello
There are several different things you could mean by it.
Here's how to join the tables to get one of them:
SELECT DISTINCT mu.mkt_id "PAR ID", mu.mkt_id "ROOT ID", msu.spec_id "ID", su.spec_desc "DESC", su.spec_cd "SPEC CD" FROM ipoadm_batch.mkt_uv1 mu LEFT OUTER JOIN ipoadm_batch.mkt_spec_uv1 msu ON msu.mkt_id = mu.mkt_id LEFT OUTER JOIN ipoadm_batch.spec_uv1 su ON msu.spec_id = su.spec_id AND su.spec_grp_or_cmpstn_cd = 'C' ;
If it does not matter what it is that you want, and then after a small example of data (CREATE TABLE and INSERT, only relevant columns instructions) for all the tables and the results desired from these data.
Highlight a few places where the above querry is the production of incorrect results of your sample data and explains how to get the correct results in these places. -
SSRS for lack of outer join with the Oracle data source
It seems to be a problem with the Oracle driver used in the Reporting SERVICES query designer.
When you use an Oracle data source, if I create an outer join in the graphic designer, it automatically inserts '{OJ' before the join and '} ' after her. This is an incorrect syntax for Oracle and refuses to start. The curly braces and the JO editable in designer text, but if I go back to the graphic designer and immediately to reintegrate them.
Only, this has started to happen a year or two ago - before that it worked, but with the old (+) syntax.
Can it not be healed? It makes things very difficult.
-Geoff
Hi Geoff,
Thanks for posting in the Microsoft Community.
However, the question you posted would be better suited in the Forums of the Oracle Support; We recommend that you post your query in Oracle Support Forums to get help:
If you have any other questions or you need Windows guru, do not hesitate to post your questions and we will be happy to help you.
-
Hello
I have a requirement in which I need to get data from a third table where a date of the third table is higher than a date in the second array.
Ex:
SELECT t1.column1, t3.column2 FROM t1, t2, t3 WHERE t1.id = t2.foreign_id AND t1.id ( + ) = t3.foreign_id AND t3.some_date_column > t2.another_date_column
However, using the query above returns no results if the date condition is not met. I still need to show t1.column1 and a null t3.column2.
How should I do this?
Thank you
Allen
Edit: Added information about the requirement.
Hi Allen
- SELECT t1.column1, t3.column2
- T1, t2, t3
- WHERE t1.id = t2.foreign_id
- AND t1.id = t3.foreign_id (+)
- AND t3.some_date_column (+) > t2.another_date_column
I guess that this t1.column1 must not be null. Or am I wrong? The + sign must be placed on the side where draws are accepted. You must repeat it for each condition on the table.
Alternativlely you can use the LEFT OUT JOIN syntax. If the two columns are allowed null you need a FULL OUTER JOIN.
BTW: The join to t2 is not required if a refefernce constraint forced.
-
need help with outer join filter.
Need a little help to filter a result set and I can't seem to find a good way to do this.
/*table*/ create table invoice( farinvc_invh_code varchar2(100), farinvc_item varchar2(100), farinvc_po varchar2(100) ) create table po( supplier_number varchar2(60), supplier_invoice_no varchar2(60), po_number varchar2(60), run_date varchar2(60), PO_LINE_NUMBER varchar2(60) );
query execution of im./*data*/ INSERT INTO "INVOICE" (FARINVC_INVH_CODE, FARINVC_ITEM, FARINVC_PO_ITEM) VALUES ('I0554164', '1', 'P0142245'); INSERT INTO "INVOICE" (FARINVC_INVH_CODE, FARINVC_ITEM, FARINVC_PO_ITEM) VALUES ('I0554164', '3', 'P0142245'); INSERT INTO "INVOICE" (FARINVC_INVH_CODE, FARINVC_ITEM, FARINVC_PO) VALUES ('I0554165', '1', 'P0142246'); INSERT INTO "INVOICE" (FARINVC_INVH_CODE, FARINVC_ITEM, FARINVC_PO) VALUES ('I0554165', '2', 'P0142246'); INSERT INTO "PO" (SUPPLIER_NUMBER, SUPPLIER_INVOICE_NO, PO_NUMBER, RUN_DATE, PO_LINE_NUMBER) VALUES ('914100121', '529132260', 'P0142245', '21-NOV-12', '1'); INSERT INTO "PO" (SUPPLIER_NUMBER, SUPPLIER_INVOICE_NO, PO_NUMBER, RUN_DATE, PO_LINE_NUMBER) VALUES ('914100121', '529137831', 'P0142245', '21-NOV-12', '3'); INSERT INTO "PO" (SUPPLIER_NUMBER, SUPPLIER_INVOICE_NO, PO_NUMBER, RUN_DATE, PO_LINE_NUMBER) VALUES ('914100121', '529137831', 'P0142245', '21-NOV-12', '2'); INSERT INTO "PO" (SUPPLIER_NUMBER, SUPPLIER_INVOICE_NO, PO_NUMBER, RUN_DATE, PO_LINE_NUMBER) VALUES ('914100122', '145678', 'P0142246', '22-NOV-12', '1'); INSERT INTO "PO" (SUPPLIER_NUMBER, SUPPLIER_INVOICE_NO, PO_NUMBER, RUN_DATE, PO_LINE_NUMBER) VALUES ('914100122', '145679', 'P0142246', '22-NOV-12', '2');
resultSELECT farinvc_invh_code, supplier_number, supplier_invoice_no, farinvc_item, farinvc_po , po_number, run_date, PO_LINE_NUMBER FROM INVOICE, PO WHERE PO_NUMBER = FARINVC_PO(+) AND FARINVC_ITEM(+) = PO_LINE_NUMBER
It is a much larger table, and I took an excerpt in order to keep things clear and understanding. I would like to filter the result set to only show lines that have po numbers are the same and line are the same but there is an additional element. in other words as such."FARINVC_INVH_CODE" "SUPPLIER_NUMBER" "SUPPLIER_INVOICE_NO" "FARINVC_ITEM" "FARINVC_PO" "PO_NUMBER" "RUN_DATE" "PO_LINE_NUMBER" "I0554165" "914100122" "145678" "1" "P0142246" "P0142246" "22-NOV-12" "1" "I0554165" "914100122" "145679" "2" "P0142246" "P0142246" "22-NOV-12" "2" "I0554164" "914100121" "529132260" "1" "P0142245" "P0142245" "21-NOV-12" "1" "I0554164" "914100121" "529137831" "3" "P0142245" "P0142245" "21-NOV-12" "3" "" "914100121" "529137831" "" "" "P0142245" "21-NOV-12" "2"
"FARINVC_INVH_CODE" "SUPPLIER_NUMBER" "SUPPLIER_INVOICE_NO" "FARINVC_ITEM" "FARINVC_PO" "PO_NUMBER" "RUN_DATE" "PO_LINE_NUMBER" "I0554164" "914100121" "529132260" "1" "P0142245" "P0142245" "21-NOV-12" "1" "I0554164" "914100121" "529137831" "3" "P0142245" "P0142245" "21-NOV-12" "3" "" "914100121" "529137831" "" "" "P0142245" "21-NOV-12" "2"
Hello
Let me assure you that I understand.
Last time, we were looking for the PO_NUMBERs who have been partially put into correspondence , i.e. groups of rows in the order table with the same po_number, which some had corresponding lines in the table Bill, and some of whom have not. It was essential that there is at least 1 line and 1 row without connections with the same purchase order.
Now that you are interested SUPPLIER_INVOICE_NOs who are partially paired, i.e. groups of rows in the table of po with the same po_number and supplier_invoice_no, some of which have corresponding lines in the invoice table, and some are not. ("Supplier_Invoice_No" is quite a mouthful. "We'll abbreviate as sin in the future.) However, the final selection is based on po_numbers: If a po_number has partially matched sins, then we are interested all po_number. For example, the result set must include = 529132260 SIN, even if that sin is completely, because there is a partially matching sin (529137831) with the same po_number (P0142245).As this problem revolves around partially matching sins, let's call them Cardinal sins . We can calculate match_cnt and total_cnt based NAS as well as po_number. Then, we can use another analytic function so see if the po_number has all cardinal_sins, like this:
WITH joined_data AS ( SELECT i.farinvc_invh_code , p.supplier_number , p.supplier_invoice_no , i.farinvc_item , i.farinvc_po , p.po_number , p.run_date , p.po_line_number , COUNT (i.farinvc_po) OVER ( PARTITION BY p.po_number , p.supplier_invoice_no ) AS match_cnt , COUNT (*) OVER ( PARTITION BY p.po_number , p.supplier_invoice_no ) AS total_cnt FROM po p LEFT OUTER JOIN invoice i ON i.farinvc_po = p.po_number AND i.farinvc_item = p.po_line_number ) , got_cardinal_sin_cnt AS ( SELECT joined_data.* , SUM ( CASE WHEN match_cnt >= 1 AND match_cnt < total_cnt THEN 1 END ) OVER (PARTITION BY po_number) AS cardinal_sin_cnt FROM joined_data ) SELECT farinvc_invh_code , supplier_number , supplier_invoice_no , farinvc_item , farinvc_po , po_number , run_date , po_line_number FROM got_cardinal_sin_cnt WHERE cardinal_sin_cnt > 0 ORDER BY po_number , farinvc_item ;
-
Problem event name: APPCRASH
Application name: need for Speed Underground 2.exe
Application version: 0.0.0.0
Application timestamp: 417d8e48
Fault Module name: need for Speed Underground 2.exe
Fault Module Version: 0.0.0.0
Timestamp of Module error: 417d8e48
Exception code: c0000005
Exception offset: 001d24c0
OS version: 6.0.6001.2.1.0.256.1
Locale ID: 1033
Additional information 1: a613
More information 2: 55689aa387c807ab900bd44bfa935768
3 more information: b5ed
Additional information 4: d06b121c03be15a74ebeeadaf13834dfHi Leinenweaverp,
Welcome to Microsoft Vista answers Forum!
I would like to ask you a few questions in order to get a better understanding of this issue.
· Were you able to load this game before and play on it?
Here are some steps that may help you.
First of all, I suggest that you perform a clean boot on the computer and install the game and make sure if you are able to load the game and play on it, you can start Windows Vista by using a minimal set of drivers and startup programs. This type of boot is known as a "clean boot". A clean boot helps eliminate software conflicts.
The following link has steps showing how to perform the clean boot: http://support.microsoft.com/kb/929135
(1) perform the clean boot (check the link to perform the clean boot)
(2) enable half the services
(3) determine whether the problem returns
(4) enable half of the startup items
(5) determine if the problem returns
(6) repeat the steps above until you find out which program or service is causing the issue
After you determine the startup item or the service that is causing the problem, contact the manufacturer of the program to determine if the problem can be solved. Or, run the System Configuration utility, and then click to clear the check box of the element of the problem.
Reset the computer to start as usual:
When you are finished troubleshooting, follow these steps to reset the computer to start as usual:
1. click on start, type msconfig.exe in the start search box and press ENTER.
If you are prompted for an administrator password or for confirmation, type your password, or click on continue.
2. on the general tab, click the Normal startup option, and then click OK.
3. When you are prompted to restart the computer, click on restart.
If the problem persists, I suggest that you contact the manufacturer of the game for further assistance, you can check the link: http://www.nfscars.net/home/index.aspx
Hope this information is useful.
Thank you, and in what concerns:
Swathi B - Microsoft technical support.
Visit our Microsoft answers feedback Forum and let us know what you think. -
Help for a LEFT OUTER JOIN query
Hello, all,.
I'm having some trouble setting up an Oracle 11 g Server SQL query, and I could use some help.
Let's say tableA is blogs; tableC is comments for blog entries; tableB is the associative array:
tableA blogID blogTitle blogBody dateEntered 1 This is a test More text... 2016-05-20 11:11:11 2 More testing Still more! 2016-05-19 10:10:10 3 Third charm!! Blah, blah. 2016-05-18 09:09:09
tableC commID userID userText dateEntered 10 Bravo I like it! 2016-05-20 11:21:31 11 Charlie I don't! 2016-05-20 11:31:51 12 Alpha Do it again! 2016-05-19 10:20:30 13 Bravo Still more? 2016-05-19 10:30:50 14 Charlie So, what? 2016-05-19 10:35:45 15 Bravo Blah, what? 2016-05-18 09:10:11 16 Alpha Magic number! 2016-05-18 09:11:13
tableB blogID commID 1 10 1 11 1 12 2 13 2 14 3 15 3 16
I'm trying to get blogID, blogTitle, blogBody and the number of comments for each blog entry. But, since I'm on to_char() for date and COUNT (commID) for the total number of comments, I am not "a group by expression.
Here is an example of pseudo-SQL of what I'm trying.
SELECT a.blogID, a.blogTitle, a.blogBody, to_char(a.dateEntered,'YYYY-MM-DD HH24:MI:SS') as dateEntered, COUNT(c.commID) as total FROM tableA a LEFT OUTER JOIN tableB b ON b.blog_ID = a.blog_ID LEFT OUTER JOIN tableC c ON c.commID = b.commID WHERE a.blogID = '1' GROUP BY blogID, blogTitle, blogBody ORDER BY to_date(dateEntered,'MM-DD-YYYY HH24:MI:SS') desc
I'm sure it's something simple, but I just DO NOT see it. Can you help me?
V/r,
^_^
Try:
GROUP BY a.blogID, a.blogTitle, a.blogBody, to_char(a.dateEntered,'YYYY-MM-DD HH24:MI:SS')
See you soon
Eddie
-
Looking for right outer join help
Hello
Can anyone help me re - write the query using right below outer join (join ansi) instead of using the (+) symbol.
Select cd.sku_id waitm,
Decode (cl.invn_lock_code, NULL, 'OH', cl.invn_lock_code) WLOCN,
Sum (CD.actl_qty) WQOH
cd, a.case_lock cl, a.case_hdr ch, a.item_master im a.case_dtl
where cd.case_nbr = ch.case_nbr
and cl.case_nbr (+) = ch.case_nbr
and cd.sku_id = im.sku_id
and ch.stat_code < = '64'
Cd.sku_id group,
IM.sku_brcd,
Decode (cl.invn_lock_code, NULL, 'OH', cl.invn_lock_code)
order of cd.sku_id
Kind regards
Gannu
Maybe something like this:
of a.case_dtl cd
Join a.case_hdr ch on (cd.case_nbr = ch.case_nbr)
Join a.item_master im on (cd.sku_id = im.sku_id)
join a.case_lock cl left (cl.case_nbr = ch.case_nbr)
where ch.stat_code<=>=>
I know you asked for right outer join, but I tend to write like that. You can certainly change if you wish.
Maybe you are looking for
-
I need to delete old email addresses in the address cache
I need to delete old addresses of e-mail addresses collected and personal address books. What does not work (final deletion; addresses not back when Thunderbird is opened later): 1) right-click and delete; (2.) to write a new email... address list co
-
Sat Pro A10: 'IDE #0 Error' on two laptops
Hello Appreciate any input from anyone in case I did something really stupid or am incredibly unlucky. A Pro A10 Sat (out of warranty) looked like an imminent drive failure, then I cloned the drive and tried to share more, but got the error IDE #0 at
-
I lost all open tabs in Firefox 4 for MAC when my computer restarts or restarts Firefox
I lost all open tabs in Firefox 4 for MAC when my computer restart or at any time to restart Firefox. Help, please
-
Useful info for people who are stuck with the Portege 3490CT
can you guys try and leave feedback? PARAMETERS of the BIOS for floppy drive and external cd/dvd usb worksStart the laptop computer while pressing the ESC key. It beep at you and displays "check system. Then press [F1]. Press the F1 key. This lets yo
-
I am unable to display mirroring on my Bravia w800A with my Samsung note 2 or my iPad 3. Pl help.