Merging two complemental result sets... or OUTER JOINs not working?
Dear experts!
Again I have a very difficult problem for which I ask Your help, but this time I am better prepared than last time and can deliver sample data of my (hopefully not too much) simplified example:
create table Subjects(
pk_id number not null primary key,
title varchar2(128)
create table People(
pk_id number not null primary key,
name varchar2(128)
create table Results(
pk_id number not null primary key,
fk_subjects_id number,
fk_people_id number,
result number
insert into Subjects(pk_id, title) values (1, 'Choosing a recipe')
insert into Subjects(pk_id, title) values (2, 'Shopping ingredients')
insert into Subjects(pk_id, title) values (3, 'Preparations')
insert into Subjects(pk_id, title) values (4, 'Cooking for beginners')
insert into Subjects(pk_id, title) values (5, 'Eating for pros')
insert into Subjects(pk_id, title) values (6, 'Dishwashing for everyone')
insert into Subjects(pk_id, title) values (7, 'Digesting for experts')
insert into Subjects(pk_id, title) values (8, 'Becoming hungry again...')
insert into Subjects(pk_id, title) values (9, 'Redo from start')
insert into People(pk_id, name) values (1, 'Hank')
insert into People(pk_id, name) values (2, 'Cloe')
insert into People(pk_id, name) values (3, 'Mary')
insert into Results(pk_id, fk_subjects_id, fk_people_id, result) values (1, 1, 1, 2)
insert into Results(pk_id, fk_subjects_id, fk_people_id, result) values (2, 2, 1, 4)
insert into Results(pk_id, fk_subjects_id, fk_people_id, result) values (3, 3, 1, 3)
insert into Results(pk_id, fk_subjects_id, fk_people_id, result) values (4, 9, 1, 5)
insert into Results(pk_id, fk_subjects_id, fk_people_id, result) values (5, 1, 2, 4)
insert into Results(pk_id, fk_subjects_id, fk_people_id, result) values (6, 2, 2, 1)
insert into Results(pk_id, fk_subjects_id, fk_people_id, result) values (7, 3, 2, 5)
insert into Results(pk_id, fk_subjects_id, fk_people_id, result) values (8, 4, 2, 2)
insert into Results(pk_id, fk_subjects_id, fk_people_id, result) values (9, 5, 2, 3)
insert into Results(pk_id, fk_subjects_id, fk_people_id, result) values (10, 6, 2, 2)
insert into Results(pk_id, fk_subjects_id, fk_people_id, result) values (11, 7, 2, 1)
insert into Results(pk_id, fk_subjects_id, fk_people_id, result) values (12, 4, 3, 3)
insert into Results(pk_id, fk_subjects_id, fk_people_id, result) values (13, 5, 3, 5)
insert into Results(pk_id, fk_subjects_id, fk_people_id, result) values (14, 7, 3, 1)
insert into Results(pk_id, fk_subjects_id, fk_people_id, result) values (15, 8, 3, 5)
insert into Results(pk_id, fk_subjects_id, fk_people_id, result) values (16, 9, 3, 1)
Please imagine this as an university for amateur cooks. Now I want to present them their performance record/"scorecard", for every student, only with her or his marks. On this performance record there should be a list of all 9 subjects possible to pass, and where students got a result, that result should be filled in. I thought that should be possible to achieve with something like this:
SELECT PEOPLE.NAME, SUBJECTS.TITLE, RESULTS.RESULT FROM RESULTS
JOIN PEOPLE ON PEOPLE.PK_ID = RESULTS.FK_PEOPLE_ID
JOIN SUBJECTS ON SUBJECTS.PK_ID = RESULTS.FK_SUBJECTS_ID
WHERE RESULTS.FK_PEOPLE_ID = 2
But also using (LEFT|RIGHT|FULL) OUTER JOINs here does not help me to get what I want, I always only get
NAME TITLE RESULT
Cloe Choosing a recipe 4
Cloe Shopping ingredients 1
Cloe Preparations 5
Cloe Cooking for beginners 2
Cloe Eating for pros 3
Cloe Dishwashing for everyone 2
Cloe Digesting for experts 1
But I want:
NAME TITLE RESULT
Cloe Choosing a recipe 4
Cloe Shopping ingredients 1
Cloe Preparations 5
Cloe Cooking for beginners 2
Cloe Eating for pros 3
Cloe Dishwashing for everyone 2
Cloe Digesting for experts 1
Cloe Becoming hungry again...
Cloe Redo from start
Without having to fill in empty rows for all students which did not take all exams yet.
Is it possible? If so, how?
Thank You very much in advance and Happy Easter to everyone! :-)
With kind regards,
Chriss
Edited by: user9355711 on 01.04.2010 07:01
Edited by: user9355711 on 01.04.2010 07:28
Edited by: user9355711 on 01.04.2010 07:29
Also;
var n number
exec :n := 2;
PL/SQL procedure successfully completed
n
2
select ppl.name, sub.title, res.result
from subjects sub, people ppl, results res
where sub.pk_id = res.fk_subjects_id(+)
and ppl.pk_id = :n
and res.fk_people_id(+) = :n
order by sub.title;
NAME TITLE RESULT
Cloe Becoming hungry again...
Cloe Choosing a recipe 4
Cloe Cooking for beginners 2
Cloe Digesting for experts 1
Cloe Dishwashing for everyone 2
Cloe Eating for pros 3
Cloe Preparations 5
Cloe Redo from start
Cloe Shopping ingredients 1
Similar Messages
-
Outer join not working when filters are applied from Prompts
Hi,
Without values being selected from the dashboard prompts, my outer join is working fine with all the rows and all the columns showing up( as per requirement). But as soon as I select values in the prompts, only certain rows and columns show up.
BTW, I have 2 prompts Year and Quarter. I put Year is Prompted or is null in the criteria. It works. BUT as soon as I also put in quarter numbers, it does not work.
Is there a workaround for this?
Thanks,
Dan
Edited by: Danny on Apr 26, 2013 12:10 PMI just experimented by adding is null to not only the year and quarter but to the row and column too and it worked!
Thanks,
Dan -
Left Outer Join Not working in BI 7.0 Infoset
Hi All,
I am working on BI 7.0. I have to create a report where I have to display the Target values from a target DSO against the transactional data (Operational data).
I have a DSO where for a subteam value target has been set up on different KPIs.
In the Info Cube, I have transactional data on daily basis per subteam. I have to show the actual and target values.
I have created an Info Set using Target DSO and Daily operational cube, so that I should able to compare the target and actual values of KPIs, for all the subteam values (From DSO, irrespective of whether the data is available in cube for those sub team).
I have used Outer Left Join in the Info set (DSO on left side), but I am unable to see the desired results. It is working just like an inner join.
Any Idea why the Outer Left Join is not working? The DSO has only one fey field called subteam on which I have set outer left join.
Regards,
AmitHi,
did you solve your problem? because I have the same issue right now: the left outer join doesn't seem to do its job.
Let me know if you have found a solution, it would be appreciated.
have a nice day,
Dominic -
Left Outer Join not working in Infoset.
Hello Friends,
I have two ODSes , one for planned data (zplan) and other is billing z ods (zsd_o03).
now the situation is such that in my planned ODS for one sold to party .
SOLD TO MATERRIAL CALMONT PLANNED QUANTIY
14315 100 06.2007 54
14315 200 06.2007 20
14315 300 06.2007 30
14315 400 06.2007 10
But in my Billing ODS iam having for Sold to 14315
SOLD TO MATERRIAL CALMONT ACTUAL QUANTIY
14315 100 06.2007 20
14315 200 06.2007 30
And my Bex ouput should be like
SOLD TO MATERIAL CALMONT planned ACTUAL QUANTIY
14315 100 06.2007 54 20
14315 200 06.2007 20 30
14315 300 06.2007 30 0
14315 400 06.2007 10 0
So for this i made one Infoset and these ODses are linked by Sold_to , Materail,
Calmonth.
First i tried using Inner joing option , but the bottom two lines were not ciming , so used left outer join , and activated and recreated the query but still its showiong me the output same as inner join .. i.e
14315 100 06.2007 54 20
14315 200 06.2007 20 30
So i checked by writing a ABAP code in Se38 , but there its showing me the correct result ..
So please anybody help me out because iam thinking that infoset is the right way to do this kind of reporting , or esle shall i make one ODS and populate it through this ABAP code..
Thanks in advance.Hi , can anybody help me in this regard..
Thanks .. -
Hello everybody,
I have a folder based on materialized view (Detailed folder). There is another folder which is based on a table (master folder). i have created a jooin and select option as "outer join on master folder". The join is not working properly. Am i doing asomething wrong. Discoverer version is 10.1.2 and database version is 10.2.0.3. i have been creating outer joins among folders based on tables but i am not sure about whats wrong this time??? materalized view defination is as follows:
CREATE MATERIALIZED VIEW MW
BUILD IMMEDIATE
REFRESH FORCE
START WITH SYSDATE
NEXT TRUNC(SYSDATE+1)+1/4
WITH PRIMARY KEY
AS
SELECT * FROM VIEW
Thanx for your help
Regards,
NajeebSo, let me see if I got this...
You have a table and a materialized view. There is a join between the two, where the table is the master, and the MV is the detail. The join is set to be an outer join on master. Ultimately, you want to see the values in the MV where the join condition is NULL.
What boggles me is that you say the query runs fine in the database, but not in Disco. This could mean that there is a condition in the BA or in the worksheet. But, if that were the case, the condition should show up in the SQL generated by Disco.
It looks like the where clause is the problem. NULL is never equal to anything, so when APPROVEDBY is null, the where clause should fail and no data returned. This explains Disco's behavior, but not SQL's.
Something to try: Create a calculation in the materialized view folder of the business area like:
NVL(APPROVEDBY, -1)
I am assuming that all of your IDs are positive. Then modify the join to use the calculated column. This should convert the NULLS to values, and the report should work. -
LEFT OUTER JOIN not working as expected
I'm testing a query from the portal. I've got two inputs:
products
{"ProductKey":1,"ProductAlternateKey":"abc","Color":"Red"},
{"ProductKey":2,"ProductAlternateKey":"def","Color":"Blue"},
{"ProductKey":3,"ProductAlternateKey":"ghi","Color":"Blue"}
And temperatures:
{"DeviceId":1,"Temperature":99},
{"DeviceId":2,"Temperature":90},
{"DeviceId":2,"Temperature":99},
{"DeviceId":3,"Temperature":50},
{"DeviceId":4,"Temperature":32}
When I test a query with an (inner) join, I get two rows, one for Red and one for Blue as expected. However, when I change to a LEFT OUTER JOIN, I would expect to get three rows... one for Red, one for Blue, and one for NULL color. However, I only get one
row with a NULL color. Here's the query. Is this a bug or am I misunderstanding?
SELECT DateAdd(second,-5,System.TimeStamp) as WinStartTime
, system.TimeStamp as WinEndTime
, b.Color
, Avg(r.Temperature) as AvgTemperature
, Count(*) as EventCount
FROM temperatures r
LEFT OUTER JOIN products b ON r.DeviceId = b.ProductKey and DATEDIFF(hour,r,b) BETWEEN -6 AND 6
GROUP BY TumblingWindow(second, 5), b.Color
(Please excuse the contrived example, the lack of timestamps, and the 12 hour window... just testing.)
http://artisconsulting.com/Blogs/GregGallowayHi Greg,
Thank you for raising this issue.
We have deployed a fix today that corrects LEFT OUTER JOIN behavior on the in-browser query testing experience.
Can you please confirm that the above query and input sources work for you?
Thanks!
Ziv. -
Dynamic From statement in select query and/or outer join not working
Dear Experts, I have a select query where the select columns are dynamic, the where condition is also dynamic. It is of the below format:
Select (dynamic columns) INTO <wa>
FROM a inner join b on af1 = bf1
inner join c on af2 = cf2......
WHERE (dynamic conditios)
ORDER BY ( dynamic sort condition).
Now I have to include some tables (dynamically depending on the user input) in the inner join statement which will give description for the selected fields. And these database tables may or may no be empty. So in this case, my select query will not return any data if these tables are empty. And I dont want that.
I tried using outer join for the extra tables but it gave me a runtime error. I also tried forming the inner join statement dynamically but it was not supporting.
Kindly give me pointers.
ThanksHey thanks for the reply, but the problem is not solved.
I am already using ( fileds, value) like table in my where condition and the select statement was working properly.
the problem is that now I have to include some tables in the join statement which can be empty and so i want to use Outer join.
But I am getting a runtime error as below:
Error analysis
An exception occurred that is explained in detail below.
The exception, which is assigned to class 'CX_SY_DYNAMIC_OSQL_SYNTAX', was not
caught in
procedure "ZATSCSNG_RFC_READ_TABLE" "(FUNCTION)", nor was it propagated by a
RAISING clause.
Since the caller of the procedure could not have anticipated that the
exception would occur, the current program is terminated.
The reason for the exception is:
The running ABAP program wanted to execute a SELECT statement whose
WHERE condition was (partly) specified dynamically. The part that is
specified in an internal table at runtime is compared to a field of the
right table of an LEFT OUTER JOIN. Such comparisons are not supported by
all database systems and are therefore not allowed. -
I have tried everything to fix the wifi dimed switch has anyone actually found a resolution, I'm not trying that stupid freezer or hair drying trick because thats just stupid....
You most likely have a failure of the WiFi chip.
Restore the phone as a new device. If that doesn't solve your problem, you'll have to bring your phone to Apple for replacement. If you are not within the warranty period, expect to pay $199 for out of warranty replacement. -
How to merge 3 different query results using full outer join?
Hi all This is my my query for 2 results
with t1 as (
select trans.crAcc_id,trans.cr_amt,row_number() over (order by trans.head_id) rn from Acttrans trans,
Acttranhead head where trans.head_id in(select link_id from acttrans where head_id=12) and trans.crAcc_id!=0
and head.head_id=trans.head_id
t2 as (
select trans.drAcc_id,trans.dr_amt,head.[Vouc_No],head.[Vouc_Date] ,head.[Check_No],head.[Check_Date],head.[stat],row_number() over (order by trans.head_id) rn from Acttrans trans,
Acttranhead head where trans.head_id=12 and trans.drAcc_id!=0
and head.head_id=trans.head_id
select t1.crAcc_id, t1.cr_amt,t2.[Vouc_No],t2.[Vouc_Date] ,t2.[Check_No],t2.[Check_Date],t2.[stat],t2.drAcc_id,t2.dr_amt from t1
full outer join t2 on t1.rn = t2.rn
Query 3: SELECT [CrAcc_Id] FROM [KSSDATA].[dbo].[ActTrans] where head_id=12 and crAcc_id!=0
and i want to add Query3 result to the ABOVE RESULT but i am unable add third result using full outer join
Thanks
Balu D>>>but i am unable add third result using full outer join
Do you get the error or wrong result?
Best Regards,Uri Dimant SQL Server MVP,
http://sqlblog.com/blogs/uri_dimant/
MS SQL optimization: MS SQL Development and Optimization
MS SQL Consulting:
Large scale of database and data cleansing
Remote DBA Services:
Improves MS SQL Database Performance
SQL Server Integration Services:
Business Intelligence -
How to Create a new column from two different result sets
How to Create a new column from two different result sets, both the result set uses the different date dimensions.
i got solutions for this is apply filters in column formula it self, based on the requirement.
-
How to return two XML result sets using the function
Hi Experts,
Thanks.So that I want to return two XML result sets if the query returns more than 50,000 records.
One XML result set with 50,000 and another XML result set with remaining records.
How to incorporate this in my function.
Have the function return a collection of CLOB then.
DBMS_XMLGEN can handle pagination so it's easy to adapt your existing code.
Here's an example fetching data in batches of max. 3 rows each, using a pipelined function :
SQL> create or replace type clob_array is table of clob;
2 /
Type created
SQL>
SQL> create or replace function genXmlRowset (p_deptno in number) return clob_array pipelined
2 is
3 ctx dbms_xmlgen.ctxHandle;
4 doc clob;
5 begin
6
7 ctx := dbms_xmlgen.newContext('SELECT empno, ename FROM scott.emp WHERE deptno = :1');
8 dbms_xmlgen.setBindValue(ctx, '1', p_deptno);
9 dbms_xmlgen.setMaxRows(ctx, 3);
10
11 loop
12
13 doc := dbms_xmlgen.getXML(ctx);
14 exit when dbms_xmlgen.getNumRowsProcessed(ctx) = 0;
15 pipe row (doc);
16
17 end loop;
18
19 dbms_xmlgen.closeContext(ctx);
20
21 return;
22
23 end;
24 /
Function created
SQL> set long 5000
SQL> select * from table(genXmlRowset(30));
COLUMN_VALUE
<?xml version="1.0"?>
<ROWSET>
<ROW>
<EMPNO>7499</EMPNO>
<ENAME>ALLEN</ENAME>
</ROW>
<ROW>
<EMPNO>7521</EMPNO>
<ENAME>WARD</ENAME>
</ROW>
<ROW>
<EMPNO>7654</EMPNO>
<ENAME>MARTIN</ENAME>
</ROW>
</ROWSET>
<?xml version="1.0"?>
<ROWSET>
<ROW>
<EMPNO>7698</EMPNO>
<ENAME>BLAKE</ENAME>
</ROW>
<ROW>
<EMPNO>7844</EMPNO>
<ENAME>TURNER</ENAME>
</ROW>
<ROW>
<EMPNO>7900</EMPNO>
<ENAME>JAMES</ENAME>
</ROW>
</ROWSET>
SQL>
(and don't forget to use bind variables in your query) -
ORA-30563, Outer Join not allowed in select list
I can not find any information about this error message that I am getting.
I have just upgraded my Oracle database from Version 7.3 to Version 8.1.7, a stored procedure that was written in v7.3 has outer joins in the select statement.
when trying to run this proc in version 8 I get this meesage.(ORA-30563, Outer Join not allowed in select list)
code ex:
Select alt.id
decode(alt.advise, NULL, NULL, AA.act_yr(+))||'-'||AA.act_per(+)||'-'||AA.Acc_per_no(+)) as advise_no
from alt, AA;
Is there any information about this message anywhere? or does anybody know if this is a known issue with oracle ver 8.1.7?
Thanks
CJIt appears to have been a bug in 7.x
From a metalink note on bugs fixed in 8i (doc 132632.1)
974742 Oracle does not report an error if (+) is specified in select-list. The OUTER JOIN operator (+) is only valid in WHERE clause predicates. As this is not flagged as an error the query can give unexpected results. The correct action to avoid this problem is to fix the query.
Ken -
The prob with this query is, it has to list the pono for grnno,which contains null value,but outer join doesn work on this, and it list values only for grnno that contains value please help to solve this prob
SELECT pv.vendor_name, pv.segment1 vendorid, ph.segment1 pono, pl.line_num,
ph.creation_date po_date, pl.quantity orderqty,
pll.quantity_received, pl.unit_price, rcv.receipt_num grn_no,
rct.creation_date item_recd_date, rct.quantity, ph.currency_code,
item.segment1 itemcode, pl.item_description description,
ph.attribute1 po_type
FROM po_headers_all ph,
po_lines_all pl,
po_vendors pv,
po_line_locations_all pll,
rcv_shipment_headers rcv,
rcv_transactions rct,
mtl_system_items item
WHERE item.inventory_item_id = pl.item_id
AND item.organization_id = pl.org_id
AND ph.authorization_status IN ('APPROVED')
AND NVL (ph.cancel_flag, 'N') = 'N'
AND NVL (pl.cancel_flag, 'N') = 'N'
AND pl.po_header_id = pll.po_header_id
AND pl.po_line_id = pll.po_line_id
AND pl.org_id = pll.org_id
AND rcv.shipment_header_id = rct.shipment_header_id
AND pl.po_header_id = rct.po_header_id
AND rct.po_line_id = pl.po_line_id(+)
AND pl.po_header_id = ph.po_header_id
AND pv.vendor_id = ph.vendor_id(+)
AND TRUNC (ph.creation_date) >= '06-MAY-2006'
AND TRUNC (ph.creation_date) <= '29-MAY-2006'
AND rct.transaction_type = 'RECEIVE'
ORDER BY ponoThis is one that always confuses me - do you need to outer join all references to the table? ie :
1 select d.deptno,d.dname
2 ,e.empno,e.ename
3 from dept d,emp e
4 where d.deptno = e.deptno(+)
5 and d.dname like '%S%'
6* and e.ename like '%A%'
SQL> /
DEPTNO DNAME EMPNO ENAME
30 SALES 7499 ALLEN
30 SALES 7521 WARD
30 SALES 7654 MARTIN
30 SALES 7698 BLAKE
20 RESEARCH 7876 ADAMS
30 SALES 7900 JAMES
6 rows selected.
SQL> edit
Wrote file afiedt.buf
1 select d.deptno,d.dname
2 ,e.empno,e.ename
3 from dept d,emp e
4 where d.deptno = e.deptno(+)
5 and d.dname like '%S%'
6* and e.ename(+) like '%A%'
SQL> /
DEPTNO DNAME EMPNO ENAME
20 RESEARCH 7876 ADAMS
30 SALES 7654 MARTIN
30 SALES 7900 JAMES
30 SALES 7521 WARD
30 SALES 7499 ALLEN
30 SALES 7698 BLAKE
40 OPERATIONS
60 TEST
70 TEST
9 rows selected. -
Revision: 4323
Author: [email protected]
Date: 2008-12-15 19:23:10 -0800 (Mon, 15 Dec 2008)
Log Message:
Bug: LCDS-544 - Scenario where two components have seperate channel sets with overlapping channels not working.
QA: Yes
Doc: No
Checkintests Pass: Yes
Details:
* Hunting to a new channel within a channelset never triggered a disconnect from the previous channel(s). This isn't a problem in general, but does becomes a problem when an app defines two distinct channelsets containing at least one shared channel at the head of the list. In this case, the first channelset hunts past it and connects on a later channel. But when the second channelset hunts through (triggering a connect fault when it hits that initial shared channel that can't connect), the fault is processed by the first channelset as well (incorrectly).
Ticket Links:
http://bugs.adobe.com/jira/browse/LCDS-544
Modified Paths:
flex/sdk/trunk/frameworks/projects/rpc/src/mx/messaging/ChannelSet.asRunning the script by python2 solves it for me:
su - mythtv -c "nice -n 19 python2 /usr/bin/tv_grab_nl_py --output ~/listings.xml"
Best regards,
Cedric -
Macbook Pro 2011 DVI HDMI out does not work with TV when the power cable is connected
My Macbook Pro (Early 2011) DVI HDMI out does not work with TV when the power cable is connected. If get the blue screen and then can use the macbook but nothing is displayed on the TV. If i go into display I can see that there are two screens but nothing displayed on the TV. If i take the power cable out at this point the TV shows the second desktop as expected. If i then reconnect the cable, the screen flickers, as though it is being affected by the power cable, and the screen goes blank on the TV. Only if i remove the DVI cable do i get the blue screen again. If i remove the power cable and reconnect it will do it every single time, so i cannot see it being a TV issue or a minor glitch.
I have had this working previously but at the minute it seems to not be playing ball....any thoughts
Thanks
DanBUMP
Any ideas?
Maybe you are looking for
-
hello forum i have an iusse with my account i have set my main region as the united states< however now i have moved to australia and i have a remaining blanace of 0.92 cents USD i want to change my country/region to Australia and use australian curr
-
Not able to post journal voucher because of unbalanced system currency
Hi I am not able to post journal voucher because of unbalanced system currency (the local currency is matching). what should be done, i have posted close to 70 entries!!!!! I am using SAP 2005B patch level 44 please help Thanks
-
PC crashes as soon as I connect my iPhone 4.
I've recently updated all my Apple applications, and iPhone 4 to iOS 7. Ever since then, my computer has been acting really strange. I thought my computer was infected, so I did a few virus scans. Fortunately, nothing came up in the virus scan res
-
Linq to Entities Multiple Children ODAC Right Paranthesis not Found
All, Oracle Version Stuff: Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64bit Production PL/SQL Release 11.2.0.2.0 - Production CORE 11.2.0.2.0 Production TNS for Linux: Version 11.2.0.2.0 - Production NLSRTL Version 11.2.0.2.0
-
FORMS 4.5: can't open file ...
with designer/2000 r2.1 i have created .fmb file in FROMS 5.0, but i cannot open .fmb file (FRM 10043) with FORMS 4.5 (developer 2000) null