Effort using Outer join parent-child relationship
Oracle Database 10 g Express Edition Release 10.2.0.1.0 - productI have the following tables
CREATE TABLE "ADDPROJECT"
( "PROJID" VARCHAR2(30) NOT NULL ENABLE,
"PROJNAME" VARCHAR2(30),
"PROJSTARTDATE" DATE,
"PROJENDDATE" DATE,
"PARENTPROJID" VARCHAR2(30),
"PROJTYPE" VARCHAR2(30),
"PROJSTATUS" VARCHAR2(30),
PRIMARY KEY ("PROJID") ENABLE
)
CREATE TABLE "ALLOCATEASSOCIATES"
( "PROJID" VARCHAR2(30) NOT NULL ENABLE,
"ASSOCIATEID" NUMBER(*,0) NOT NULL ENABLE,
"ALLOCATIONSTARTDATE" DATE,
"ALLOCATIONPERCENT" NUMBER(*,0),
"ENDDATE" DATE,
PRIMARY KEY ("PROJID", "ASSOCIATEID") ENABLE
)
CREATE TABLE "ADDRESEARCHAREA"
( "RAID" VARCHAR2(30) NOT NULL ENABLE,
"RANAME" VARCHAR2(30),
"RASTARTDATE" DATE,
"RAENDDATE" DATE,
"PARENTRAID" VARCHAR2(30),
"RASTATUS" VARCHAR2(30),
PRIMARY KEY ("RAID") ENABLE
)
CREATE TABLE "PROJECTTORAASSOCIATION"
( "RAID" VARCHAR2(30) NOT NULL ENABLE,
"PROJID" VARCHAR2(30) NOT NULL ENABLE,
"STARTDATE" DATE,
"ENDDATE" DATE,
"STATUS" VARCHAR2(30),
PRIMARY KEY ("RAID", "PROJID") ENABLE
)
insert into addresearcharea values ('ra1','raname1',to_date('04/01/2012','mm/dd/yyyy'),'','','Active')
insert into addresearcharea values ('ra2','raname2',to_date('04/01/2012','mm/dd/yyyy'),'','','Active')
insert into addresearcharea values ('ra3','raname3',to_date('04/01/2012','mm/dd/yyyy'),'','','Active')
insert into addresearcharea values ('ra4','raname4',to_date('04/01/2012','mm/dd/yyyy'),'','ra1','Active')
insert into addresearcharea values ('ra5','raname5',to_date('04/01/2012','mm/dd/yyyy'),'','ra1','Active')
insert into addresearcharea values ('ra6','raname6',to_date('04/01/2012','mm/dd/yyyy'),'','ra2','Active')
insert into addproject values ('proj1','projname1',to_date('04/01/2012','mm/dd/yyyy'),'','','Research','Active')
insert into addproject values ('proj2','projname2',to_date('04/01/2012','mm/dd/yyyy'),'','','Research','Active')
insert into addproject values ('proj3','projname3',to_date('04/01/2012','mm/dd/yyyy'),'','','Research','Active')
insert into projecttoraassociation values ('ra1','proj1',to_date('04/01/2012','mm/dd/yyyy'),'','Active')
insert into projecttoraassociation values ('ra4','proj1',to_date('04/01/2012','mm/dd/yyyy'),'','Active')
insert into projecttoraassociation values ('ra2','proj2',to_date('04/01/2012','mm/dd/yyyy'),'','Active')
insert into projecttoraassociation values ('ra3','proj3',to_date('04/01/2012','mm/dd/yyyy'),'','Active')
insert into allocateassociates values ('proj1',1,to_date('04/01/2012','mm/dd/yyyy'),100,'')
insert into allocateassociates values ('proj1',2,to_date('04/01/2012','mm/dd/yyyy'),100,'')
insert into allocateassociates values ('proj2',3,to_date('04/01/2012','mm/dd/yyyy'),100,'')
In short, here is the dataResearch areas: ra1, ra2, ra3
Void / areas of research for AM1: ra4, ka5
Void / areas of research for ra2: qxf6
Void / areas of research for ra3: -.
Projects - proj1, proj2.proj3
Mapping of the area of research projects
Proj1: ra1 and ra4
Proj2: ra2
Associate the allocation
Proj1: 1,2
Proj2: 3
I need to get wise effort search space and subarea displayed on the same row (if the project is also associated with the search of sub box)
The user must be able to choose a particular area of research and the results displayed accordingly
Results expected in the cases where no specific research field are selected
EFFORT PROJECTID PROJECTNAME RANAME SUBRANAME
12.70 proj1 projname1 raname1 ra4
6.35 proj2 projname2 raname2 -
- proj3 projname3 raname3 -
Production in the event of main search box is selected (for example:-ra1)EFFORT PROJECTID PROJECTNAME RANAME SUBRANAME
12.70 proj1 projname1 raname1 ra4
The expected results in the area of research case void are selected (for example:-ra4)EFFORT PROJECTID PROJECTNAME RANAME SUBRANAME
12.70 proj1 projname1 raname1 ra4
The query I wroteSELECT
to_char(
SUM(
(MONTHS_BETWEEN(
1+LEAST(
LEAST(
LEAST(
nvl(ar.raenddate,to_date('04/01/2100','mm/dd/yyyy'))
,nvl(pr.enddate,to_date('04/01/2100','mm/dd/yyyy')))
,nvl(aa.enddate,to_date('04/01/2100','mm/dd/yyyy')))
,sysdate),
GREATEST(
GREATEST(
GREATEST(
ar.rastartdate
,pr.startdate)
,aa.allocationstartdate)
,to_date('04/01/2012','mm/dd/yyyy')))
* aa.allocationpercent / 100
))
,999.99) AS EFFORT,
aa.projid AS PROJECTID,
ap.projname AS PROJECTNAME,
ar.raname AS RANAME,
ar2.raid AS SUBRANAME
FROM AllocateAssociates aa,ProjecttoRAAssociation pr,addProject ap,AddResearchArea ar, AddResearchArea ar2
WHERE pr.projid = aa.projid (+)
AND aa.projid = ap.projid
AND pr.raid = ar.raid
AND ar.raid = ar2.parentraid (+)
group by aa.projid,ap.projname,ar.raname,ar2.raid
The problems I am facing1. I need to get a list of projects that are associated with the search box even if they have no allocation of project. Although I used the outer join, I don't get this result. I used the full outer join, but gave the expected result. (Since there are several tables to assemble. maybe something wrong to join to?) (in the above data, proj3 must also be displayed even if it doesn't have an allocation of project)
2. If a search box has more than one field of research, there are 2 entries for each sub research field even if the project has been associated with the search under a single box (in the above data, the proj1 has been associated with ra4 only, but the results display the ra4 and ka5)
3. the query shows two entries for the main research area and one for the research sub area (provided that the project is associated with the correct principal and under research field). But there should be just an entry in a space research containing the name of the two main and under research field
Please help me to solve these problems.
Tags: Database
Similar Questions
-
Add an object 3d without parent/child relationship.
Hello
I have a scene of 3d picture control, I have two objects in there, but when I created the scene I had to use the add object invoke node objects in the scene, so there is a parent/child relationship between the objects, which means that if I move the parent, I also move the child object. Is there a way to create a scene with several objects without the parent/child relationship.
Thank you.
-Luis
Hello, I solved it by first moving the objects and then adding them to the scene. -Luis
-
parent/child relationship hirarchy
Hi everyone, consider the sample data
SELECT LFROM '1TR1Y6', NULL LTO, MID '11ZFDD', '21XHK7' double UNION ALL TID-
SELECT '1TR1YF' LFROM, LTO NULL, '11ZFDD' MI '21XHK5' TID FROM dual UNION ALL-
SELECT '1TR1X1' LFROM, LTO NULL, '11ZFDD' MI '21XHK8' TID FROM dual UNION ALL-
SELECT '1LSZX1' LFROM, LTO NULL, '11ZFDD' MI '1TR1YD' TID FROM dual UNION ALL-
SELECT LFROM "1LSZWQ", "21XHK7" LTO, MID '11ZFDD', '1TR1Y6' TID FROM dual UNION ALL-
SELECT LFROM "1LSZX2", "21XHK5" LTO, MID '11ZFDD', '1TR1YF' TID FROM dual UNION ALL-
SELECT LFROM "1LSZVG", "21XHK8" LTO, MID '11ZFDD', '1TR1X1' TID FROM dual UNION ALL-
SELECT LFROM "4LSSVG", "21XHK9" LTO "11AAA' MI '1TR1X1' TID double UNION ALL
SELECT "AAAAA" LFROM, LTO NULL, '11ABB' e, 'CCCCCC' double UNION ALL TID
SELECT "BATH" LFROM, 'CCCCCC' LTO, MID '11ABB', 'AAAAA' double UNION ALL TID
some of them have a parent/child releationship. for example, let take rank with LFROM = 1TR1Y6
1TR1Y6 (lfrom) corresponds to the fifth line with TID 1TR1Y6. TID 1TR1Y6 LTO COLUMN value corresponds to the first line TID (21XHK7)
It before these two LINES are IN a parent/child relationship.
lets take another example. LINE two WITH LFROM = 1TR1YF matches sixth RANK WITH TID 1TR1YF. the sixth LINE LTO COLUMN (21XHK5) corresponds to the SECOND TID of LINE.
Once again the parent child relationship. There are two lines that do not have the relationship of parent/child (ex. line 8)
Im trying to write a query that can partition the data in the middle column and find the parent/child relationship. the output of the above data should be
LTO LFROM MIDDLE TID FLAG
1TR1Y6 NULL 11ZFDD 21XHK7 1
1LSZWQ 21XHK7 11ZFDD 1TR1Y6 1
1TR1YF NULL 11ZFDD 21XHK5 1
1LSZX2 21XHK5 11ZFDD 1TR1YF 1
1TR1X1 NULL 11ZFDD 21XHK8 1
1LSZVG 21XHK8 11ZFDD 1TR1X1 1
1LSZX1 NULL 11ZFDD 1TR1YD 0
4LSSVG 21XHK9 11AAA 1TR1X1 0
ABDELKÉBIR 11ABB CCCCCC NULL 1
CCCCCC 11ABB AAAAA BATH 1
For simplicity, I posted the release with parent/child, side by side in the sequence. the order does not matter as long as the flag column (pull the column) is set to an appropriate value (1 if parent/child, 0 no parent/child)
the flag column value is derived from column to indicate the parent/child relationship was found.
I try using lead, the lag function but I have problem of sorting data from parent and child line could come at random order (they are not side by side).
It is therefore difficult to use lead because you don't know how many lines to carry forward.
can someone help me write a query that displays the output above
SELECT T1. LFROM,
T1. LTO,
T1. ENVIRONMENT,
T1. TID,
(
SELECT COUNT (*)
OF TBL T2
WHERE)
T2. TID = T1. LFROM
OR
T2. LFROM = T1. TID
)
AND T2. MI = T1. MID
) FLAG
OF TBL T1
/
LTO LFROM MIDDLE TID FLAG
------ ------ ------ ------ ----------
1LSZWQ 21XHK7 11ZFDD 1TR1Y6 1
1LSZX2 21XHK5 11ZFDD 1TR1YF 1
1LSZVG 21XHK8 11ZFDD 1TR1X1 1
CCCCCC 11ABB AAAAA BATH 1
1TR1X1 11ZFDD 21XHK8 1
1TR1X1 11ZFDD 21XHK8 1
1LSZX1 11ZFDD 1TR1YD 0
1TR1Y6 11ZFDD 21XHK7 1
ABDELKÉBIR 11ABB CCCCCC 1
1TR1YF 11ZFDD 21XHK5 1
4LSSVG 21XHK9 11AAA 1TR1X1 011 selected lines.
SQL >
SY.
-
using outer joins if the two column is null? Use only (+)
Hi all
create the table xxc_tr_num (tl_number number, tr_no number tl_no_id);
insert into xxc_tr_num values (123,100,222);
insert into xxc_tr_num values (124,100,333);
create the table xxc_od_tab (tl_number number, tl_id number);
insert into xxc_od_tab values (123,001);
insert into xxc_od_tab values (null, null);
create table xxc_oth_tab (name varchar2 (10), number of tl_id);
insert into xxc_oth_tab values('abc',,001);
insert into xxc_oth_tab values (null, null);
Wait it out put
tr_no tl_no_id name
100 222 abc
100 333
using outer joins if the two column is null? use only please of outer joins
And I tried to use outer joins on both tl_id column but not get values and I use have County (tr_no ) > 1
Rajesh123 wrote:
Thank you Kiss it is not possible to use having clause?
You need to understand the functioning of the group. If you will not be asked this question.
Check this box
SQL> select tr_no, 2 tl_no_id, 3 count(*) 4 from xxc_tr_num a, 5 xxc_od_tab b, 6 xxc_oth_tab c 7 where a.tl_number = b.tl_number(+) 8 and b.tl_id = c.tl_id(+) 9 group 10 by tr_no 11 , tl_no_id; TR_NO TL_NO_ID COUNT(*) ---------- ---------- ---------- 100 333 1 100 222 1
See what returns the count? You have grouped according to TR_NO and TL_NO_ID. You must take into consideration the TL_NO_ID just put COUNT (TR_NO) does not increase the NUMBER of the whole group. To get the NUMBER on the whole group, I used the analytical function and did. Like this, see the number of the analytical function here
SQL> select tr_no, 2 tl_no_id, 3 count(*), 4 count(*) over(partition by tr_no) 5 from xxc_tr_num a, 6 xxc_od_tab b, 7 xxc_oth_tab c 8 where a.tl_number = b.tl_number(+) 9 and b.tl_id = c.tl_id(+) 10 group 11 by tr_no 12 , tl_no_id; TR_NO TL_NO_ID COUNT(*) COUNT(*)OVER(PARTITIONBYTR_NO) ---------- ---------- ---------- ------------------------------ 100 222 1 2 100 333 1 2
So to answer your question, yes you can't do in the HAVING clause...
-
in the query and parent/child relationship
WITH the data AS
(
SELECT '213NY1' lfrom, NULL, '215ZVD' mi lto, "215ZV9 ' id, 1 January 2014' sdate, January 2, 2014' edate, 3 January, 2014 'mdate' January 5, 2014 medate double UNION ALL.
Lfrom SELECT NULL, '215ZVD' mi, id "213NY1", "215ZV9" lto 4 January 2014 'sdate', 6 January 2014 edate, January 7, 2014 'mdate', 8 January 2014 medate double UNION ALL
SELECT '216TVZ' lfrom, NULL, "213JW7" e "217LVQ" id lto, 21 January, 2014 'sdate' January 9, 2014 edate, 10 January 2014 'mdate', 11 January 2014 medate double UNION ALL
SELECT lfrom "215Y71", "217LVQ" lto, mi, "216TVZ" id "213JW7", 22 January, 2014 'sdate' January 23, 2014 edate, 24 January, 2014 'mdate' January 25, 2014 medate double UNION ALL
SELECT '234IJF' lfrom, NULL, "234YU" e "3IUED" id lto, 26 January 2014 'sdate', 27 January 2014 edate, 28 January 2014 'mdate', 29 January 2014 medate OF double
)
some lines have parent/child relationship and some does not. for example, the first two query (data) are link together. online, the value of lto (215ZV9) corresponds to the id value
in line 1. the value of lfrom in row1 (213NY1) corresponds to the value of online id.
the same scenario occurs in rows 3 and 4. 5th doesn't have any line which is a child. tier 5 is a single parent
I want to WRITE a query that gives the following result.
Mid id initial_date final_date
=======================================
215ZVD 215ZV9 1 January 2014 "January 5, 2014"
"215ZVD 213NY1 7 January 2014" January 6, 2014 "
"213JW7 217LVQ 21 January 2014 ' 11 January 2014"
"213JW7 216TVZ 24 January 2014 ' 23 January 2014"
"234YU 3IUED 26 January 2014 ' 27 January 2014"
ONLY WHEN there is a parent/child relationship, initial DATE AND follow the final data WHAT such as
FIRST date of deadline DATE
< Mdate > < EDate > - for child
< SDate > < MEDate > - for parent
WHEN there is no relationship of parent/child (e.g. ONLY a parent ROW) THEN
FIRST date of deadline DATE
< SDate > < EDate-> parent
can someone help me write a query for the above output
with tt AS
(SELECT a.*,
ROW_NUMBER () ON LV (MIDDLE ORDER BY SDATE PARTITION),
CASE
WHEN ID = NVL (ADVANCE (lto, 1) OVER (PARTITION BY Middle ORDER BY sdate), LAG (lfrom) OVER (ORDER BY sdate Middle PARTITION))
THEN 1
END flg
DATA one
)
SELECT THE MIDDLE,
ID,
CASE
WHEN flg IS NOT NULL
THEN
CASE
WHAT LV = 1
THEN SDATE
WHAT LV = 2
THEN mDATE
END
Of ANOTHER sdate
END INITIALDATE
CASE
WHEN flg IS NOT NULL
THEN
CASE
WHAT LV = 1
THEN mEDATE
WHAT LV = 2
THEN EDATE
END
Of ANOTHER edate
END FINALDATE
TT;
Output:
-------------
MID ID INITIALDATE FINALDATE
213JW7 217LVQ 21 January 2014 January 11, 2014
213JW7 216TVZ 24 January 2014 23 January 2014
215ZVD 215ZV9 January 1, 2014 5 January 2014
215ZVD 213NY1 January 7, 2014 6 January 2014
234YU 3IUED 26 January 2014 January 27, 2014
-
Implementation of Parent / child relationships
How to define a group of elements (symbols placed on the stage) as children of another element. When I drag/select the Group of elements that are the children and drop them on top of the element that must be the parent, the relationship is not to be trained and the 'drop' is not currently permitted.
I guess I must be watching older videos because the tutorials I have seen has indicated that dragging a layer on top of the other in the assets Panel would lead the moved element becomes the child of the element on which it was abandoned, but this doesn't seem to work.
Thank you.
Andy.
Hi, Andy.
Yes, it should work, but there are some types of items that may not be parents, like Text and Image divs. You can try to draw a rectangle, then by dragging on it. If this does not work, let us know so that we can begin to study more deeply.
Thank you
-Elaine
-
Parent - child relationship constraint Unique 5.0 apex oracle
Oky so I will try to avoid duplicate values get inserted in the parent-child node.
So basically when there's a node parent (Mobile) I can't create same node with the same name.
Even for the child node, if there is a child node name there may be another named A.
Structure:
Mobile (parent) /Android (Child) /KitKat (subchild) (allowed)
Mobile/apple/ios(Now allowed Same Parent name)
Win7/Windows/win7(not allowed same child)
So a big child and the parent must be unique at any time.
create an index of single "TEST_UK" on tablename (parent_id, upper (child_name));
see this too for a case-insensitive unique constraint
-
I have multiple instances of an object, and I would like to make the changes that I put on one of these objects in order to perpetuate and change on the other instances of the object
turn your object into a symbol and place several instances of it on the artboard when you edit the symbol of all instances will be updated.
-
Simulate the 1 - N N - N relationship using the Parent-child structure
Hello
I have a 1-N relation between SKILL tables and the USER, which means 1 skill can be applied to multiple users. A jurisdiction may have a parent jurisdiction, which means that a ParentSkill inherits all the privileges of his child.
I would like to simulate a N - N relation between the users and the skills by building a vision that goes through the parent-child relationship. This is possible for the construction?
Current structure:
Favorite exit (the skillid order is not important):|USERID | USERNAME | SKILLID | +-------+----------+----------+ | 1 | Jack | 1 | | 2 | Simon | 1 | | 3 | Fred | 3 | +-------+----------+----------+ |SKILLID | DESCRIPTION | PARENTSKILL | +--------+---------------+--------------+ | 1 | Mechanic | 2 | | 2 | Inspector | 3 | | 3 | Supervisor | null | +--------+---------------+--------------+
|USERID | USERNAME | SKILLID | +-------+----------+----------+ | 1 | Jack | 1 | | 2 | Simon | 1 | | 3 | Fred | 3 | | 3 | Fred | 2 | | 3 | Fred | 1 | +-------+----------+----------+
I hope that answers your needs:
WITH users as ( SELECT 1 as USERID, 'Jack' as USERNAME, 1 as SKILLID FROM DUAL UNION ALL SELECT 2 as USERID, 'Simon' as USERNAME, 1 as SKILLID FROM DUAL UNION ALL SELECT 3 as USERID, 'Fred' as USERNAME, 3 as SKILLID FROM DUAL ), skills as ( SELECT SKILLID,CONNECT_BY_ROOT SKILLID AS ANCESTORS FROM ( SELECT 1 as SKILLID, 'Mechanic' as DESCRIPTION, 2 as PARENTSKILL FROM DUAL UNION ALL SELECT 2, 'Inspector', 3 FROM DUAL UNION ALL SELECT 3, 'Supervisor', NULL FROM DUAL ) CONNECT BY PRIOR PARENTSKILL = SKILLID ) SELECT USERID,USERNAME,ANCESTORS FROM skills, users WHERE users.skillid = skills.skillid /
USERID USERN ANCESTORS ---------- ----- ---------- 1 Jack 1 2 Simon 1 3 Fred 3 3 Fred 2 3 Fred 1
I hope this helps!
-
show on a monthly basis, using the outer join
Hello
I use an example of emp table to describe my problem here
I made a request that is group by hiredate months and showing the sum of wages.
as follows,
Select
TO_DATE (to_char(HireDate,'MON-RRRR'), MON-RRRR), sum (sal)
Of
EMP
Group by
TO_DATE (to_char(HireDate,'MON-RRRR'), MON-RRRR)
SQL > /.
TO_DATE (T SUM (SAL)
--------- ----------
FEBRUARY 1ST, 10 21000
MARCH 1, 10 30000
MAY 1, 10 43000
1ST JUNE 10 70000
what I want is to show also the months too where any recruitment made
as
month sum (sal)
January 1 10 0
FEBRUARY 1ST, 10 21000
MARCH 1, 10 30000
April 1, 10 0
MAY 1, 10 43000
1st June 10 0
1ST JUNE 10 70000
August 1 10 0
0 01-sept.-10
1 October 10 0
1 November 10 0
1 December 10 0
I've tried doing another table with month AND use outer join, but failed to get the result
any ideas will be appreciatedChange the following query accordingly as directed by your data
Select
ADD_MONTHS (to_date (January 1, 2001 "," dd-MON-RRRR'), level - 1) MonthName
Of
Double
connect by level<=>=>It gives data for 2001
If your emp table is to have 2010 data while it was being replaced by add_months (to_date (January 1, 2010 "," dd-MON-RRRR'), level - 1) MonthNameAlexander gelin
http://nimishgarg.blogspot.comEdited by: Caroline Geffroy 10 June 2010 18:11
-
There are four tables:
Family
Parent
Child
Grandchild
Ideally, they have all documents, such as
F1 - P1 - C1 - G1
F2 - P2 - C2 - G2
F3 - P3 - C3 - G3
But sometimes,.
F1 - P1 - C1 - null
F2 - P2 - null - null
F3 - P3 - null - null
For the case of the latter, maybe I need to right outer join. If it's between two tables, the right outer join is easier. But among the four tables, inner family join parent, child of the outer join, then the big kid outer join. Maybe even this has been done? If an outer join in this case is not relevant, what other options are available?
Thank you
(ORACLE 11.2)Hello
As Salomon, said
FROM p LEFT OUTER JOIN c
means exactly the same thing that
FROM c RIGHT OUTER JOIN p
Everything you do with LEFT OUTER JOIN you could also do with RIGHT OUTER JOIN, and vice versa. If either one did not exist, you may do whatever you want with the other. In practice, it's just what's happening: most of the people always use LEFT OUTER JOIN and never use a RIGHT OUTER JOIN.
You can have a series of outer joins cascading. If I understand your problem, a particular family may or may not have parents that belongs to him. If there are relatives, then you want to show the family with his parents to realteaed, but if there are no parents, so you want to show the family anyway. Similarly, you want to show parents whether or not they have children, and the children or not all my grandchildren are related to them. In general, which is written like this:
... FROM family f LEFT OUTER JOIN parent p ON p.family_id = f.family_id LEFT OUTER JOIN child c ON c.parent_id = p.parent_id LEFT OUTER JOIN grandchild g ON g.child_id = c.child_id
You can have a situation where (for example) a child is related to a family, but the child has no parent? In this case, you can still use LEFT OUTER JOIN, but join conditions would be different.
-
Sum of a stand-alone parent-child table
I have two tables - a 'key' table containing a parent-child relationship of multi-layer and a table 'amount' that contains the keys for the nodes in the key as well as table of numeric values (for example the amounts).
I want a query that returns each line in the table of key as well as the sum of the amount amounts of the table for the set of nodes of this key (so the root node would be the sum of all values of quantity).
Here's what I mean: I have two tables, the KEY and the AMOUNT
KEY has two columns, keys, and parent_key; key and parent_key have a relationship CONNECT BY parent_key = prior key (with null for the root parent_key):
AMOUNT a two columns, keys, and amount; key points to KEY.key and amount is a value for that particular keyKEY PARENT_KEY 0 null 1 0 2 0 3 0 1A 1 2A 2 2B 2 3A 3 3B 3 3C 3 1A1 1A 1A2 1A 2A1 2A 2A2 2A 2B1 2B 3A1 3A 3A2 3A 3C1 3C 3C2 3C
(Note that all key values are leaf nodes in the KEY table)
What I want is a result that looks like this, where the amount of each key is the sum of the amounts of its possible keys sheetKEY AMOUNT 1A1 1 1A2 2 2A1 3 2A2 4 2B1 5 3A1 6 3A2 7 3C1 8 3C2 9
For example, the value of the key 2 a, 7, is the sum of the values of 2 a 1 and a 2, 2; key value of 3 is the sum of 3 a 1, a 3, 2, 3, C 1 and 2 of 3.KEY AMOUNT 0 45 1 3 2 12 3 30 1A 3 2A 7 2B 5 3A 13 3B 0 3C 17 1A1 1 1A2 2 2A1 3 2A2 4 2B1 5 3A1 6 3A2 7 3C1 8 3C2 9
Is it possible to do this with a single query?
The idea I came with is, do a select on the KEY with a "Key CONNECT_BY_PATH" column so that each line contains a string that contains the keys of all his ancestors and then do a join on AMOUNT with IN the CONNECT_BY_PATH amount.key column; However, with a large amount of data, it takes a little time. Is there a way faster / more obvious to achieve?OK you have almost everything you need. Outer join just your two tables, and then perform a hierarchical query, noting the key root of each tree. Then group the data set resulting:
with t1 as (select '0' "KEY", '' parent_key from dual union all select '1', '0' from dual union all select '2', '0' from dual union all select '3', '0' from dual union all select '1A', '1' from dual union all select '2A', '2' from dual union all select '2B', '2' from dual union all select '3A', '3' from dual union all select '3B', '3' from dual union all select '3C', '3' from dual union all select '1A1', '1A' from dual union all select '1A2', '1A' from dual union all select '2A1', '2A' from dual union all select '2A2', '2A' from dual union all select '2B1', '2B' from dual union all select '3A1', '3A' from dual union all select '3A2', '3A' from dual union all select '3C1', '3C' from dual union all select '3C2', '3C' from dual ), t2 as (select '1A1' "KEY", 1 amount from dual union all select '1A2', 2 from dual union all select '2A1', 3 from dual union all select '2A2', 4 from dual union all select '2B1', 5 from dual union all select '3A1', 6 from dual union all select '3A2', 7 from dual union all select '3C1', 8 from dual union all select '3C2', 9 from dual ), t3 as ( select t1.key, parent_key, amount from t1 left join t2 on t1.key = t2.key ), t4 as ( select CONNECT_BY_ROOT key root_key , level lv , t3.* from t3 connect by prior t3.key = parent_key ) select root_key "KEY", sum(amount) amount from t4 group by root_key order by length(root_key), root_key;
-
Default filters that users can delete (in the parent/child Setup)?
Is it possible in Latitude 2.2.2 to have filters (filters of the range, refinement filters etc.) applied by default (which means that users see these filters when they log-in), but they can also remove (using bread crumbs portlet) if they wanted to? We tried to use the source of data (JSON) filters (using 'baseFunctions' setting) where we have a parent/child Setup, but it seems these filters cannot be removed once applied. Note that filters can be removed if we do not have a parent/child relationship between the data sources, but as soon as we introduce a parent/child relationship between the data sources (which we need), the GET of sticky filters and cannot be deleted. Any reason why the parent/child relationship causes the filters becoming sticky? Any way (alternate) to reach what we want?I think that it is a known problem (LSTUDIO-5088) and there could be a fix for this. You can contact technical support to obtain the fix.
Dave
-
You can force BI outer join in w/o logical SQL Anwser in the Advanced tab
In the repository of BI, we Protocol, region, Site of Protocol, Dimension of the object and a table of facts containing the physical tables Protocol, region, site and subject as a source in MDB.
The relationship is that a protocol can have 0, n regions, region 0, n sites and a site 0, n subject, with the fact table of the region contains Protocol WID and done Site contains the Protocol and Feds region, subject is contains the Protocol, the region and Site Feds.
In reporting on the Protocol and the region, BI users would like to have all the protocols appear in the report, without worrying if a protocol contains regions or not. Even as the Protocol-region-Site reports, etc. I can create these reports with SQL logic in the Advanced tab to force BI joins external Protocol, region or Site, etc.. However, users of BI would be difficult to write these SQLs.
It seems to me that BI server always uses an inner join in the SQLs generated when the user selects the attributes of Protocol, region and Sites, etc. I played with constant implicit approach.
I know that I can use outer join to define the logic Table Source in the layer of MDB. Would this tangle Protocol, region and site, tables etc. in MDB? What is the best practice to the MDB template when you want compatible outer join?
Is there a way to force the BI server to generate outer join in the answers?
Thanks in advance,
Shi-ningJoins using external in the layer MDB is not recommended because it brings in the tables in the query and also impact performance. The right way to handle this scenario is the ETL.
Add a record to the dimension tables with 0 for the ROW_WID and NULL values for the rest of the columns
All of fact records without valid WID values for the dimension of research must have a value of 0 instead
Now when we try to do an INTERNAL JOIN between the fact and any dimension, even those made documents that donot have a valid WID value will also be part of the result. It is essentially an OUTER JOIN operation. -
Fusion of data/result defines what are parent/child?
Hello:
I have seen a few examples to make a data model so that a BI report can have master-detail data. They are a set of Q1 data and a set of T2 data with a variable binding to connect the two in a parent/child relationship.
But what I need, it is actually a UNION. I have the same table on multiple instances of database and I want to show the results grouped in a single report, as if it all happened to a table. Examples of master-detail have a section defining the grouping but they group Q1 (see here)
http://blogs.Oracle.com/BIDeveloper/data_template/
and I need to regroup in a column in Q1 and Q2 to "merge" the two sets of data.
Does anyone do this?
Thank you.If you define multiple SQL-queries/data models data sets, you can combine them into a single set of data by selecting the concatenated SQL Data Source.
Choose concatenate them box, concatenation will result in the union.
RTF again, you can use the two dataset and display as a single table.
Maybe you are looking for
-
My TB version 31.1.0 and 31.1.2 drop-down menu commands and commands "right button" very slow... All other menu programs bars will work perfectly. Tried disabling McAfee, no diff. TB collects e-mails, wrote e-mails to a normal speed without problem.
-
looking for download HP MediaSmart 3.0.28.2 Version exe so I have the volume control bar on my desktop screen when I adjust thanks volume level
-
How can I recover files from formatted drive?
I deleted my local disk accidentily main c:\ or maybe formatted on the accident. Now my hard drive is not it. anyway to get that back Original title: messed up my hard drive
-
At work, I take calls all day. Whenever a new call comes in, I have about 5 different programs all popping them, staggered throughout on a second time 90. Whenever a window opens, it interrupt what I'm trying to type because the window, that I beco
-
How to transfer address book from 1 computer to another
cannot transfer my address book from my lapto to my new laptop Windows 7 vista. I'm using windows mail.