Inline query vs cross join
Hi all
Two tables which have no relationship with each other. For example, an Employees table and a systemparameter with a startworktime table.
We need a query with the data in the two tables:
Get all employees and the startworktime (which is the same for everyone)
Which is cheaper: an inline query or a product Cartesian or crossjoin?
Inine:
Select name, function
(by selecting startworktime in systemparameter)
employees;
Cartesian product:
SELECT name, function, startwoime
rktfrom used
Cross join systemparameter;
Your opinion about this.
Both these do the same thing. I seriously doubt if we would have the benefits of performance on the other.
Kind regards
Tags: Database
Similar Questions
-
Difference between a CROSS JOIN and a Cartesian product of the noted comma?
Hello everyone,
Oracle version: Oracle Database 11 g Enterprise Edition Release 11.2.0.1.0 - 64 bit
OS: Linux Fedora Core 17 (x86_64)
I was practicing on recursive subquery factoring based on oracle examples available in the documentation
http://docs.Oracle.com/CD/E11882_01/server.112/e26088/statements_10002.htm#i2129904
I was working on an example that displays the hierarchy of each manager with related employees. Here's how
Which gives the desired resultWITH tmptab(empId, mgrId, lvl) AS ( SELECT employee_id, manager_id, 0 lvl FROM employees WHERE manager_id IS NULL UNION ALL SELECT employee_id, manager_id, lvl+1 FROM employees, tmptab WHERE (manager_id = empId) ) SEARCH DEPTH FIRST BY mgrId SET order1 SELECT LPAD(' ', lvl * 3, ' ') || empId AS empId FROM tmptab;
However, by chance, I noticed that if I put CROSS JOIN instead of put a comma between table names, the same query behaves differently.EMPID --------------------- 100 101 108 109 110 111 112 113 200 203 204 205 206 102 103 104 105 106 107 114 115 116 117 118 119 120 125 126 127 128 180 181 182 183 121 129 130 131 132 184 185 186 187 122 133 134 135 136 188 189 190 191 123 137 138 139 140 192 193 194 195 124 141 142 143 144 196 197 198 199 145 150 151 152 153 154 155 146 156 157 158 159 160 161 147 162 163 164 165 166 167 148 168 169 170 171 172 173 149 174 175 176 177 178 179 201 202 107 rows selected. SQL>
In other words, if instead of writing
I am writing. . . UNION ALL SELECT employee_id, manager_id, lvl+1 FROM employees, tmptab WHERE (manager_id = empId)
I get the following error message. . . UNION ALL SELECT employee_id, manager_id, lvl+1 FROM employees CROSS JOIN tmptab WHERE (manager_id = empId)
Any idea?ERROR at line 4: ORA-32044: cycle detected while executing recursive WITH query
Correct me if I'm wrong, but I remember, oracle supports as many JOIN CROSSROADS notation for Cartesian product (vector product =). For example
So if the two rated commas and CROSS JOIN have the same semantics, why do I get a cycle mentioned above cites recursive subquery factoring while the same query works pretty well with comma between table instead of CROSS JOIN names? Because if a cycle is detected (= current element ancestor) it means that the product with the CROSS JOIN notation produces duplicates which are absent in the result of the Cartesian product rated comma.SQL> WITH tmptab1 AS 2 ( 3 SELECT 'a1' AS colval FROM DUAL UNION ALL 4 SELECT 'a2' AS colval FROM DUAL UNION ALL 5 SELECT 'a3' AS colval FROM DUAL 6 ), 7 tmptab2 AS 8 ( 9 SELECT 'b1' AS colval FROM DUAL UNION ALL 10 SELECT 'b2' AS colval FROM DUAL 11 ) 12 SELECT t1.colval, t2.colval 13 FROM tmptab1 t1 CROSS JOIN tmptab2 t2; CO CO -- -- a1 b1 a2 b1 a3 b1 a1 b2 a2 b2 a3 b2 6 rows selected. SQL> LIST 13 13* FROM tmptab1 t1 CROSS JOIN tmptab2 t2 SQL> SQL> SQL> CHANGE /CROSS JOIN/, 13* FROM tmptab1 t1 , tmptab2 t2 SQL> SQL> SQL> LIST 1 WITH tmptab1 AS 2 ( 3 SELECT 'a1' AS colval FROM DUAL UNION ALL 4 SELECT 'a2' AS colval FROM DUAL UNION ALL 5 SELECT 'a3' AS colval FROM DUAL 6 ), 7 tmptab2 AS 8 ( 9 SELECT 'b1' AS colval FROM DUAL UNION ALL 10 SELECT 'b2' AS colval FROM DUAL 11 ) 12 SELECT t1.colval, t2.colval 13* FROM tmptab1 t1 , tmptab2 t2 SQL> SQL> / CO CO -- -- a1 b1 a2 b1 a3 b1 a1 b2 a2 b2 a3 b2 6 rows selected. SQL>
I would appreciate it if you could kindly shed some light.
Thanks in advance,
Kind regards
DariyooshHello
dariyoosh wrote:
... Oracle terminology could become really confusing. But once again, according to the online glossary, a Cartesian product is apparently regarded as a join
http://docs.Oracle.com/CD/E11882_01/server.112/e25789/glossary.htm?type=popup#CNCPT44493
>There is no doubt that a Cartesian product (also called cross join) is a join. If loops in a WITH recursive clause are detected after completing the joins, but before other conditions apply, the relevant question here is "what are the requirements to join?
In the ANSI syntax, the distinction is always clear. Join conditions occur in the... Clause WESELECT employee_id, manager_id, lvl + 1 FROM employees JOIN tmptab ON (manager_id = empId) -- Join condition ;
and other conditions occur in the WHERE (or HAVING or CONNECT BY) clause.
SELECT employee_id, manager_id, lvl + 1 FROM employees CROSS JOIN tmptab WHERE (manager_id = empId) -- NOT a join condition ;
In the joins of the former, it seems to be the case that any condition involving 2 or more tables (or the + indicator of outer join) is a condtion of join:
SELECT employee_id, manager_id, lvl + 1 FROM employees , tmptab WHERE (manager_id = empId) -- Join condition ;
-
Extract multiple lines using the technique of the cross join
Hello.
Can someone suggest a method to return 3 lines of a query when otherwise would return only one line?
I am trying to reach the analog SQL logic to this topic-
Reason: I want a result three rows (n) force and use GROUP BY with case statements to create 3 levels summary.SELECT x.foo, p.id, p.name FROM people p CROSS JOIN (SELECT 1 AS foo UNION ALL SELECT 2 UNION ALL SELECT 3) x;
Here is a simple SQL logical expression that works for my setup - OBI
But I think that I can't do--SELECT "- Nx_CSDG0_Repair_Orders (Depot Repair Views)".Repair_Number saw_0, "- Nx_CSDG0_Repair_Orders (Depot Repair Views)".SR_Operating_Unit_Name saw_1 FROM "[Noetix-NoetixGlobalRepository] NoetixViews for Oracle Service" WHERE ("- Nx_CSDG0_Repair_Orders (Depot Repair Views)".Repair_Number = '338246')
But what peut do?SELECT "- Nx_CSDG0_Repair_Orders (Depot Repair Views)".Repair_Number saw_0, "- Nx_CSDG0_Repair_Orders (Depot Repair Views)".SR_Operating_Unit_Name saw_1 FROM "[Noetix-NoetixGlobalRepository] NoetixViews for Oracle Service" CROSS JOIN (SELECT 1 AS foo UNION ALL SELECT 2 UNION ALL SELECT 3) WHERE ("- Nx_CSDG0_Repair_Orders (Depot Repair Views)".Repair_Number = '338246')
Thank you.
-csHi CSeelig,
The BI server uses the ANSI SQL standard. Then all the SQL that follows this specification in OBIEE will work.
I did an example with intensification:
http://gerardnico.com/wiki/dat/OBIEE/logical_sql/obiee_sql_densificationYou will see a cross join to make a densification.
See you soon
Nico -
Hello
I wrote the following query, which works very well:
Now, I need to apply a cross thereon join:select * from ( select to_char(SCB_OPENTIME, 'YYYY-MM') as curr_date, SCB_TASK from EM_DATA_MSR_SC ) pivot ( count(SCB_TASK) for curr_date in ( '2011-01', '2011-02', '2011-03', '2011-04', '2011-05', '2011-06', '2011-07', '2011-08', '2011-09', '2011-10', '2011-11', '2011-12' ) );
When I try to run this query, I get this error message:select * from ( select to_char(SCB_OPENTIME, 'YYYY-MM') as curr_date, SCB_TASK from EM_DATA_MSR_SC where EMSCG_STATUS = status.name ) pivot ( count(SCB_TASK) for curr_date in ( '2011-01', '2011-02', '2011-03', '2011-04', '2011-05', '2011-06', '2011-07', '2011-08', '2011-09', '2011-10', '2011-11', '2011-12' ) ) cross join ( select 0, 'Closed' as name from DUAL union select 1, 'Denied' from DUAL union select 2, 'Open' from DUAL ) status;
However, SQL is supposed to have brought on a deep level table references."STATUS"."NAME": invalid identifier
I'm doing something wrong?Hello
If this is what you want, then you don't want a cross join. The inner join in the view online with no name is the only reference to beaches you need.
with ranges as ( select 0, 0 as mini, 20 as maxi from DUAL union select 1, 21, 50 from DUAL union select 2, 51, 300 from DUAL ) select * from ( select r.mini, r.maxi, to_char (t.DAT, 'YYYY-MM') as curr_date, t.NUM from TEST t join RANGES r on t.NUM >= r.mini and t.NUM <= r.maxi ) pivot ( count(NUM) for curr_date in ( '2011-01', '2011-02', '2011-03', '2011-04', '2011-05', '2011-06', '2011-07', '2011-08', '2011-09', '2011-10', '2011-11', '2011-12' ) ) ORDER BY mini ;
Depending on your data and your needs, you might want an outer join, not an inner join, like this:
... from RANGES r LEFT OUTER JOIN TEST t on t.NUM >= r.mini and t.NUM <= r.maxi
Published by: Frank Kulash, November 7, 2011 12:20
Alternative ADED of outer join -
[8i] need help with full outer join combined with a cross join...
I can't understand how to combine a full outer join with a different type of join... is it possible?
Here are some create table and insert for examples of database:
And, the results that I want to get:CREATE TABLE my_tab1 ( record_id NUMBER NOT NULL , workstation VARCHAR2(4) , my_value NUMBER CONSTRAINT my_tab1_pk PRIMARY KEY (record_id) ); INSERT INTO my_tab1 VALUES(1,'ABCD',10); INSERT INTO my_tab1 VALUES(2,'ABCD',15); INSERT INTO my_tab1 VALUES(3,'ABCD',5); INSERT INTO my_tab1 VALUES(4,'A123',5); INSERT INTO my_tab1 VALUES(5,'A123',10); INSERT INTO my_tab1 VALUES(6,'A123',20); INSERT INTO my_tab1 VALUES(7,'????',5); CREATE TABLE my_tab2 ( workstation VARCHAR2(4) , wkstn_name VARCHAR2(20) CONSTRAINT my_tab2_pk PRIMARY KEY (workstation) ); INSERT INTO my_tab2 VALUES('ABCD','WKSTN 1'); INSERT INTO my_tab2 VALUES('A123','WKSTN 2'); INSERT INTO my_tab2 VALUES('B456','WKSTN 3'); CREATE TABLE my_tab3 ( my_nbr1 NUMBER , my_nbr2 NUMBER ); INSERT INTO my_tab3 VALUES(1,2); INSERT INTO my_tab3 VALUES(2,3); INSERT INTO my_tab3 VALUES(3,4);
I tried a number of different things, google my problem and no luck yet...workstation sum(my_value) wkstn_name my_nbr1 my_nbr2 --------------------------------------------------------------- ABCD 30 WKSTN 1 1 2 ABCD 30 WKSTN 1 2 3 ABCD 30 WKSTN 1 3 4 A123 35 WKSTN 2 1 2 A123 35 WKSTN 2 2 3 A123 35 WKSTN 2 3 4 B456 0 WKSTN 3 1 2 B456 0 WKSTN 3 2 3 B456 0 WKSTN 3 3 4 ???? 5 NULL 1 2 ???? 5 NULL 2 3 ???? 5 NULL 3 4
So, what I want, it's a full outer join of t1 and t2 on workstation and a cross join of one with the t3. I wonder if I can't find examples of it online because it is not possible...SELECT t1.workstation , SUM(t1.my_value) , t2.wkstn_name , t3.my_nbr1 , t3.my_nbr2 FROM my_tab1 t1 , my_tab2 t2 , my_tab3 t3 ...
Note: I'm stuck dealing with Oracle 8i
Thank you!!Hello
The query I posted yesterday is a little more complex that it should be.
My_tab2.workstation is unique, there is no reason to make a separate subquery as mt1. We can join my_tab1 to my_tab2 and get the SUM in a subquery.SELECT foj.workstation , foj.sum_my_value , foj.wkstn_name , mt3.my_nbr1 , mt3.my_nbr2 FROM ( -- Begin in-line view foj for full outer join SELECT mt1.workstation , SUM (mt1.my_value) AS sum_my_value , mt2.wkstn_name FROM my_tab1 mt1 , my_tab2 mt2 WHERE mt1.workstation = mt2.workstation (+) GROUP BY mt1.workstation , mt2.wkstn_name -- UNION ALL -- SELECT workstation , 0 AS sum_my_value , wkstn_name FROM my_tab2 WHERE workstation NOT IN ( -- Begin NOT IN sub-query SELECT workstation FROM my_tab1 WHERE workstation IS NOT NULL ) -- End NOT IN sub-query ) foj -- End in-line view foj for full outer join , my_tab3 mt3 ORDER BY foj.wkstn_name , foj.workstation , mt3.my_nbr1 , mt3.my_nbr2 ;
Thanks for posting the CREATE TABLE and INSERT statements, and very clear expected results!
user11033437 wrote:
... So, what I want, it's a full outer join of t1 and t2 on workstation and a cross join of one with the t3.She, exactly!
The trickiest part is when and how get SUM (my_value). You could address the question of exactly what my_tab3 must be attached to a cross that's exactly what should look like the result set of the full outer join between my_tab1 and my_tab2 to. To do this, take your desired results, remove columns that do not come from the outer join complete and delete duplicate rows. You will get:workstation sum(my_value) wkstn_name ----------- ------------- ---------- ABCD 30 WKSTN 1 A123 35 WKSTN 2 B456 0 WKSTN 3 ???? 5 NULL
So the heart of the problem is how to get these results of my_tab1 and my_tab2, which is done in the subquery FOJ above.
I tried to use auto-documenté in my code names. I hope you can understand.
I could spend hours explaining the different parts of this query more in detail, but I don't know that I would lose some of that time, explain things that you already understand. If you want an explanation of the specific element (s), let me know. -
Hello.
Why Cross join on a table without specifying alias does not work properly ?
with t1 as ( select 1 as q1, 2 as q2 from dual union select 3, 4 from dual union select 5, 6 from dual ) select * from t1 cross join t1 order by 1 Q1 Q2 Q1 Q2 ---------- ---------- ---------- ---------- 1 2 1 2 1 2 1 2 1 2 1 2 3 4 3 4 3 4 3 4 3 4 3 4 5 6 5 6 5 6 5 6 5 6 5 6 9 rows selected
11.2.0.3.0 - 64 bit
2837285 wrote:
Ok.
Why 10 gr 2 we have error ORA-00918 (same self-join) and 11 g works, but the wrong result?
Why don't you ask Oracle via a support request, it's a bug.
You can't say he is working on 11g "but which gives bad result." Clearly if it is to give a wrong result then it doesn't work.
What happens on 11g is the fact that it runs without the exception of ambiguous column. There are a few known bugs in the way SQL ANSI has implemented compared to the regular SQL Oracle syntax. Oracle worked to correct.
I don't have 12 c to test, but it may have already been corrected in this version.
-
Hello
I use OBIEE version 11.1.1.6.0. I created made dummy table and column in the physical layer. and join all the dimension table with this fact. but I don't know how the business model to deal with it. can someone help me to create a cross join?
Thank you
Published by: 968086 on October 30, 2012 12:59 AMFollow this link
http://www.rittmanmead.com/2009/08/Oracle-BI-EE-10-1-3-4-1-reporting-on-non-transactional-dimension-values-equivalence-of-outer-joins/Score pls help if
-
How create/update files when the original Version is based on a query of outer join?
Hi gurus,
I created a custom page where I use a table-style area where I question my VO records, based on a query of outer join. This query contains my table looks, where I would like to insert/update records, and joined the table of standard elements, which is external with my custom table.
When I now question my files in the t, I have a record for each record in the table section, which is ok, but when I 'Refresh' some fields of my custom table and attempt to commit, I get the message "unable to complete the transaction on record. Cause: The record has been deleted by another user. "Action: cancel the transaction and re - query records to get new data.
The reason why because a record is to be inserted rather than updating because in fact there is not yet in my custom table.
The reason why I'm using the outer join, is because I don't want the user to create a record for each item one by one.
There is no work around for this?
Thanks in advance!
BR
GuyHello
You can try this.In your EntityImpl.java to extend OAPlsqlEntityImpl.
Override the updateRow() method and coding your insert statement to insert into a table custom here.
Don't forget, you must ignore the lines for which your custom table columns are null-Idris
-
I was asked if the veiw (select what is wrttien to make the view) has a cross join and follwing some ANSI compliance. So my question is... as table 3 below is used by alias tp and same table3 is used by alias tp2... commandeer that be considered as a cross join?
Sorry, I'm very new to SQL...
Published by: user11168115 on May 14, 2009 12:43select col1, col2, col3 from table1 t, table2 t1, table3 tp where --- --- --- AND tp.phs_id = (SELECT tp2.phs_id FROM table3 tp2 WHERE tp2.id = tsp.id AND ROWNUM < 2)
Hello (and welcome)
No, would not be a CROSS JOIN, since your alias tp2 JOINED tp (I guess you mean tp even if you have a TSP). A CROSS JOIN is where no JOIN condition at all is specified for a table (also known as the Cartesian product ), and if it's compatible ANSI SQL will actually be the words CROSS JOIN specified in the JOIN clause. For example:SELECT * FROM table1 CROSS JOIN table2;
Otherwise, non-compliant ANSI:
SELECT * FROM table1, table2;
-
I hope it's a quick.
I'm OK with standard inner joins that links the two tables, but what would the syntax to query three supports like this:
tbl_Nominations
NominationID (PK)
Nomination
LodgeID (foreign key to tbl_Lodges)
tbl_Lodges
LodgeID (PK)
Lodge
CountryID (Foreign Key to t/l_Countries)
tbl_Countries
CountryID
Country
Whereas for any given LodgeID I can show:
Lodge, the appointment and the country?
Thank you.
Just to say that I figured it - left outer joins, no outer joins, so:
SELECT * FROM nominations LEFT OUTER JOIN hosts designations. LodgeID = lodges. LodgeID LEFT OUTER JOIN continents we'RE staying. ContinentID is the continents. ContinentID
gives me what I was looking for.
-
How do the query select outer join to a report of the APEX
Hi all
I'm Ann.
I have a select statement that is used to calculate statistics for a month (October 2012 in this example)
Select ph.phase_number
sum ((case
WHEN ph.date_finished IS NULL or ph.date_finished > last_day (TO_DATE (' ' Oct 2012 ', ' MY YYYY' "))
THEN last_day (TO_DATE (' ' Oct 2012 ', ' MY YYYY' "))
Of OTHER ph.date_finished
END)
(-ph.date_started + 1) / count (def.def_id) as avg_days
Ph phase_membership
inner join court_engagement this on ph.mpm_eng_id = ce.engagement_id
join in-house defendant def on ce.defendant_id = def.def_id
where def.active = 1
and ph.date_started < = last_day (TO_DATE (' ' Oct 2012 ', ' MY YYYY' "))
and ph.active = 1
and UPPER (ce.court_name) LIKE '% '.
Rollup Group (phase_number)
;
The result is as below
Phase_Number AVG_DAYS
Phase One 8.6666666666666667
Phase two 14.6
Phase three 12
11.4615365
I have another list of selection mainly the list of months between two date value.
Select to_char (which_month, 'LUN YYYY') as display_month
de)
Select add_months (to_date (' ' August 2012 ', ' MY YYYY' "), rownum-1) which_month
of object
where
rownum < = months_between (to_date (' ' Oct 2012 ', ' MY YYYY' "), add_months (to_date (' ' August 2012", "MY YYYY"), - 1))
order of which_month)
The query result is as below
DISPLAY_MONTH
AUGUST 2012
SEP 2012
OCT 2012
Is it possible I can join these two select statement above to generate a comparable result:
Days of month Phase number Avg
August 2012 Phase One 8.666
Sep 2012 Phase One 7.66
Oct 2012 Phase One 5,66
August 2012 Phase two 8.666
Sep 2012 Phase two 7.66
Oct 2012 Phase two 5,66
August 2012 Phase three 8.666
Sep 2012 Phase three 7.66
Oct 2012 Phase three 5,66
Or
Days of month Phase number Avg
August 2012 Phase One 8.666
August 2012 Phase two 7.66
August 2012 Phase three 5,66
Sep 2012 Phase One 8.666
Sep 2012 Phase two 7.66
Sep 2012 Phase three 5,66
Oct 2012 Phase One 8.666
Oct 2012 Phase two 7.66
Oct 2012 Phase three 5,66
And it can be controlled by Phase number or month.
My other colleague suggested I should use a left outer join, but after having tried many ways, I'm still stuck.
I tried select is
Select a.display_month, b.* in)
Select to_char (which_month, 'LUN YYYY') as display_month
de)
Select add_months (to_date (' ' August 2012 ', ' MY YYYY' "), rownum-1) which_month
of object
where
rownum < = months_between (to_date (' ' Oct 2012 ', ' MY YYYY' "), add_months (to_date (' ' August 2012", "MY YYYY"), - 1))
order which_month)) a left outer join
(Select to_char (ph.date_finished, 'MY YYYY') as join_month, ph.phase_number)
sum ((case
WHEN ph.date_finished IS NULL or ph.date_finished > last_day (TO_DATE (a.display_month, 'MY YYYY'))
THEN last_day (TO_DATE (a.display_month, 'MY YYYY'))
Of OTHER ph.date_finished
END)
(-ph.date_started + 1) / count (def.def_id) as avg_days
Ph phase_membership
inner join court_engagement this on ph.mpm_eng_id = ce.engagement_id
join in-house defendant def on ce.defendant_id = def.def_id
where def.active = 1
and ph.date_started < = last_day (TO_DATE (a.display_month, 'MY YYYY'))
and ph.active = 1
and UPPER (ce.court_name) LIKE '% '.
To_char (ph.date_finished, 'MY YYYY'), group (phase_number) rollup) b
On a.display_month = b.join_month
but then I get an error
SQL error: ORA-00904: "A." "" DISPLAY_MONTH ": invalid identifier
I need to view a report on the APEX with option for people to download at least format CSV.
Already 1 inteactive report in the page, so I don't think adds another interactive report without using the iframe trick.
If any of you have any ideas, please help.
Thank you very much.
AnnHello Ann,.
Frank has done a very good job. I am also impressed.
Is in regard to your correction to his question, the problem is on this replacement you did
last_day(TO_DATE(am.which_month,'MON YYYY'))
AM.which_month is already a date type, and you don't need to convert it to this day.
Here is the correct way:last_day(am.which_month)
There are also sometimes with the data you've posted have no line for this month. So I also added a function NVL to display 0 under avg_days for these cases.
Here is my corrected query:
DEFINE startmonth = "Aug 2012"; DEFINE endmonth = "Oct 2012"; WITH all_months AS ( SELECT ADD_MONTHS(to_date('&startmonth','MON YYYY'), ROWNUM-1) AS which_month , ADD_MONTHS(to_date('&startmonth','MON YYYY'), ROWNUM ) AS next_month from all_objects where rownum <= months_between(to_date('&endmonth','MON YYYY'), add_months(to_date('&startmonth','MON YYYY'), -1)) ) SELECT TO_CHAR (am.which_month, 'Mon YYYY') AS month , ph.phase_number , NVL(sum ( (CASE WHEN ph.date_finished IS NULL OR ph.date_finished > last_day(am.which_month) THEN last_day(am.which_month) ELSE ph.date_finished END ) - ph.date_started + 1 ) / count(def.def_id), 0) as avg_days FROM all_months am LEFT OUTER JOIN a_phase_membership ph PARTITION BY (ph.phase_number) ON am.which_month <= ph.date_started AND am.next_month > ph.date_started AND ph.date_started <= last_day(am.which_month) -- May not be needed AND ph.active = 1 LEFT OUTER JOIN a_engagement ce ON ph.mpm_eng_id = ce.engagement_id AND ce.court_name IS NOT NULL -- or something involving LIKE LEFT OUTER join a_defendant def ON ce.defendant_id = def.def_id AND def.active = 1 GROUP BY ROLLUP(phase_number, am.which_month) ORDER BY am.which_month , ph.phase_number ; The output is: MONTH PHASE_NUMBER AVG_DAYS -------- -------------------- ---------- Aug 2012 PHASE ONE 0 Aug 2012 PHASE THREE 0 Aug 2012 PHASE TWO 0 Sep 2012 PHASE ONE 12 Sep 2012 PHASE THREE 1 Sep 2012 PHASE TWO 9 Oct 2012 PHASE ONE 8 Oct 2012 PHASE THREE 0 Oct 2012 PHASE TWO 14 PHASE ONE 11 PHASE THREE 1 PHASE TWO 11.5 9.71428571
I don't know if that's really what you want. In the case check it and let me know.
Kind regards.
Al -
How to get the inline query which is drawn from the TAB specific Application.
Hi all I use 10.2.0.4.0 oracle version.
I want to capture the sql that is raised in my prod database when an applicaton tab is hit as it takes about 5 minutes for the tab to be loaded. So is it possible, for the inline sql, which is the origin of the problem, directly from the prod environment.
(Note: I looked through the browser session in PROD DB for the query, but there, I found a lot of meetings and a lot of requests, I do not know how to distinguish the session being created by the specific tab I hit).>
Hello
I want to capture the sql that is triggered to my database of prod
When an applicaton tab is hit as it takes about 5 minutes so that the tab
to be loaded. So is it possible to get the inline sql, which is
the origin of the problem, directly from the prod environment.Please, please tell us that you have a Test environment? Log into that, then run a trace.
No doubt you can either descend all test for a few miinutes and/or
easily distinguish sessions on your Test System? That's exactly what the test
the environments are for.The SQL execution will be the same - you can go try to find
the root cause of the problem.HTH,
Paul...
-
NQSError 14020 query executing Cross-fact
I get the following error message when you try to run a query cross-fact in OBIEE answers:
State: HY000. Code: 10058. [NQODBC] [SQL_STATE: HY000] [nQSError: 10058] A general error occurred. [nQSError: 14020] None of the fact tables are compatible with the D3 of the query. X. (HY000)
I've implemented a new RPD with only 4 tables and made sure that all levels of content have been set up correctly, but I still get the error. I have the following configuration:
Physics
I have 2 tables of facts and three dimensions
F1 <-D1, D2
F2 <-D2, D3
MDB
I have a fact tables and three dimension tables:
F <-D1, D2, D3
I created a dimension for each dimension table higherarchy and kept the logical levels by two default - Total and retail.
Each dimension table has a unique LTS set to the level of "Detail".
The fact table has two LTS, and levels are set up as follows:
F1: D1 = Detail, D2 = Detail, D3 = Total
F2: = Total D1, D2 is Detal, D3 = detail
Answers
I am trying to run the following query in OBIEE answers: D1.x, D2.x, D3.x
Could someone could point me in the right direction?
-TimHi Tim,.
In your request, you have just the dimensions? How about you have measure in this report and check if you still have the same error.
I see your LTS settings well (as you have merged the individual facts in MDB). Generally, the query according to dimensions must go through setting relationships and so here, he must go through different facts well;). Could you post your request so that we can have a look?
Thank you
Diakité -
How to rewrite the query without inline query
Hello people,
I have this request trying to rewrite with a single outer join. As previously with the inline its taking too much time (one day). I was wondering if this is how I rewrite. Thanks to a bouquet. I know there must be indexed on the event.
Published by: user11961230 on May 2, 2012 12:28original : select e.event_id, EVENT_STATUS_CODE, EVENT_TYPE_CODE, c.client_code, trunc(DATE_EXTRACTED), trunc(DATE_SUBMITTED), trunc(CLS.DATE_RETURNED), trunc(DATE_TYPED), trunc(REJECT_DATE), SUM_BILLED "bill_ttl", SUM_PAID, SUM_AMOUNT "Recoveries", trunc(DATE_OF_INCIDENT), recspec.USER_REAL_NAME, recspec.LEVEL_B_CODE, trunc(STAGE_CREATED_DATE), REJECT_CODE, ISO_ERROR FROM EVENT E, CLIENT C, MV_RECOVERYDET_EVENT_SUM MV_R, CLS_SEND CLS, MV_BILLDETAIL_EVENT_SUM MV_BDE, (SELECT EVENT_ID, USER_REAL_NAME, LEVEL_B_CODE FROM END_USER EU, EVENT_END_USER EEU WHERE EEU.END_USER_ID = EU.END_USER_ID AND OWNER_FLAG = 'Y') recspec WHERE E.EVENT_ID = MV_R.EVENT_ID(+) AND E.EVENT_ID = MV_BDE.EVENT_ID(+) AND E.EVENT_ID = recspec.EVENT_ID(+) AND E.EVENT_ID = CLS.EVENT_ID(+) AND E.CLIENT_ID = C.CLIENT_ID AND E.CLIENT_ID = '1078'; After rewritting select e.event_id, EVENT_STATUS_CODE, EVENT_TYPE_CODE, c.client_code, trunc(DATE_EXTRACTED), trunc(DATE_SUBMITTED), trunc(CLS.DATE_RETURNED), trunc(DATE_TYPED), trunc(REJECT_DATE), SUM_BILLED "bill_ttl", SUM_PAID, SUM_AMOUNT "Recoveries", trunc(DATE_OF_INCIDENT), EU.USER_REAL_NAME, EU.LEVEL_B_CODE, EU.USER_REAL_NAME, EU.LEVEL_B_CODE, trunc(STAGE_CREATED_DATE), REJECT_CODE, ISO_ERROR FROM EVENT E, CLIENT C, MV_RECOVERYDET_EVENT_SUM MV_R, CLS_SEND CLS, MV_BILLDETAIL_EVENT_SUM MV_BDE, END_USER EU, EVENT_END_USER EEU WHERE E.EVENT_ID = MV_R.EVENT_ID(+) AND E.EVENT_ID = MV_BDE.EVENT_ID(+) --AND E.EVENT_ID = recspec.EVENT_ID(+) AND E.EVENT_ID = CLS.EVENT_ID(+) AND E.CLIENT_ID = C.CLIENT_ID AND EEU.END_USER_ID = EU.END_USER_ID AND EEU.EVENT_ID(+) = E.EVENT_ID AND OWNER_FLAG = 'Y' AND E.CLIENT_ID = '1078'; ?
PX stuff, it's just the 'pipes' oracle uses to divide your table into pieces and the pieces of transformation. You don't have much control that beyond doing Oracle use parallel queries or not. I guess that you can specify a degree, but this isn't your problem, anyway. But if you're curious, PX is mentioned here. http://docs.Oracle.com/CD/B12037_01/server.101/b10752/ex_plan.htm
Using index becomes a little more complicated with outer joins, because they return the rows that do not match the table conduct. If the index will be useful on the tables of conduct. It is possible to what I was looking to take advantage of the index because each row of the table is returned to the outer join. If you want to limit who then you need some sort of filter condition and an index on that column filter would be useful.
Published by: watch on 2 may 2012 17:20
-
Help of query SQL - inner joins and the separate results
Hello
ASP VB, SQL Server
I have a structure of data base with 3 tables - users, albums and photos. each user has a identifier unique, each record has a unique albumid and also contains a column with the user name. each record in the photo has a unique id so that store the user name and the album in which the image belongs.
I'm writing a query that returns a list of the albums for a particular user (based on a user name query string) and who will also bring back the id of the first record in the table for each of these albums photo.
the closest I get is to run a query to select albumid albums where userid = varuserid with a join internal on the pictures table to remove the photo ID - problem I then it comes out all the photos from the photos table where userid = varuserid, so when I do a repeat region to display a list of albums for a certain user It produces a list of all the photos where userid = varuserid
I really want to return just a list of ID album based on the username variable, but also to return the first record in the table of photos for each of these albumids
I tried different combinations of inner joins, select distinct etc but no joy.
any suggestion would be appreciated as am floundering here...
First, you must define 'first' with regard to the photos. Is there a
timestamp? They are numbered inside the album? Do you really care who is
"first", or do you want simply a shot? You also neglected to indicate if they are
empty photo albums have been allowed. I assumed that the empty albums are not
allowed.Whatever you decide, the answer will be similar.
SQL Server tends to get better results with joins with subqueries. You will have
See such a written request more often with subqueries, and there isn't
nothing wrong with that, but I'll use a join on a derived table. I have
have not all column names (hint, hint), so I made them, but the
Comments should help out you.SELECT A.Title, P.PhotoID, P.Caption, A.AlbumID, P.ImagePath
FROM dbo. A albums
-build a table derived, consisting of photo ID lowest for each
album.
INNER JOIN (SELECT AlbumID, MIN (PhotoID) AS FirstPhoto FROM dbo. Photos
AlbumID GROUP) AS PM WE A.AlbumID = PM. AlbumID
-details of the photo for the photo shown in the table above
INNER JOIN dbo. Photos P on A.AlbumID = P.AlbumID AND
H. FirstPhoto = P.PhotoID
User A.UserID ='some WHERE '"tedstar" wrote in message
News:ee4pfn$de$1@forums. Macromedia.com...
> I am writing a query that returns a list of the albums for a
> particular user (based on a user name query string) and also bring
> return
> the id of the first record in the table for each of these albums photo.
Maybe you are looking for
-
Satellite Pro P300 always try to boot first from CD/DVD
Hello world I have a problem with my laptop Satellite pro p300 PSPCDE: my OS is on my HARD drive (hdd1 with a ssd and hhd 2 is empty).In the bios on the boot sequence, I have just put (my ssd) first HDD1, HDD2 (which is empty), then drive diskette, t
-
Copy and paste a cell in a multicolumn Listbox
Nice day. I have a simple but delicate issue here. How can I allow the copy and paste (CTRL + C CTRL + V) function for a single cell to a multicolumn Listbox? I have developed an application using the multicolumn list box and then I found that I can'
-
Windows Media Player - the problem event name: BEX
Hi meet Microsoft I have Windows 7 Ultimate 32 bit I tried to read an AVI on Windows Media Player, but I get an error saying that Windows media that Layer has stopped working. Here are the details of the problem Signature of the problem:Problem event
-
E260 wont turn on its own or connected to the computer
When I plugged my e260 in my brother's computer, it wouldn't connect to windows (it was charing on the menu), so I unplugged and plugged again. Repeated several times and my player no longer works. (off) I try new tn on... but no luck... I is not eve
-
Error when sending a shared calendar calendar invitation.
Hello The situation is like this. Unable to send the invitation to a shared calendar calendar. Error message "Cannot display the form required to view this message." The user is user A wizard and has access to her calendars. Generally, she is able to