Cross join to Hi in oracle
Hello
I have below the text values.
Platimum
Silver
VIP
Bronze
I want to get cross-from above like four
Platimum | Silver | VIP | Bronze |
Platimum | VIP | Silver | Bronze |
Platimum | Bronze | VIP | Silver |
Platimum | Silver | VIP | Bronze |
And so on. It should give me 16 combinations that I guess.
How can I achieve this?
Kind regards
Mahesh
Another way to generate permutations (if nocycle seems suspicious)
with
data in the form of
(select "Platimum" val of union double all the)
Select 'Cash' of all the double union
Select 'VIP' of all the double union
Select "Bronze" double
),
permutator (swap) as
(select val
from the data
Union of all the
Select swap. «, » || Val
data,.
permutator
where instr (permutation, val) = 0
)
Select the permutation
of the permutator
where regexp_count (permutation, ',') = 3
order by swapping
PERMUTATION |
---|
Bronze, Platimum, silver, VIP |
Bronze, Platimum, VIP, Silver |
Bronze, Silver, Platimum, VIP |
Bronze, Silver, VIP, Platimum |
Bronze, VIP, Platimum, Silver |
Bronze, Silver, VIP, Platimum |
Platimum, Bronze, silver, VIP |
Platimum, Bronze, Silver, VIP |
Platimum, silver, Bronze, VIP |
Platimum, silver, VIP, Bronze |
Platimum, VIP, Bronze, silver |
Platimum, VIP, silver, Bronze |
Silver, Bronze, Platimum, VIP |
Silver, Bronze, VIP, Platimum |
Money, Platimum, Bronze, VIP |
Silver, Platimum, VIP, Bronze |
Silver, VIP, Bronze, Platimum |
Silver, VIP, Platimum, Bronze |
VIP, Bronze, Platimum, silver |
VIP Bronze, silver, Platimum |
VIP, Platimum, Bronze, silver |
VIP, Platimum, silver, Bronze |
VIP, silver, Bronze, Platimum |
VIP, money, Platimum, Bronze |
Tags: Database
Similar Questions
-
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.
-
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 ;
-
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
-
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 -
[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. -
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
-
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 -
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;
-
Update/join script to the oracle server
Im trying to create a script using two tables in my oracle server.
Developer SQL im trying to use these two different tables
Table 1: conductorinfo
Table2: calkva
I want to join the two tables based on two fields:
Condsize
Condmatl
(because the two tables have these fields) And based on these games of field, update the field conductorinfo of the table "calckva", because currently we have not these data in the conductorinfo table
This is the script I came up with:
UPDATE conductorinfo
JOIN INTERNAL Calkva
ON conductorinfo.condsize = calkva.condsize
AND conductorinfo.condmatl = calkva.condmatl
SET conductorinfo.calkva = calkva.calculatedkva
WHERE conductorinfo.condsize = calkva.condsize
AND conductorinfo.condmatl = calkva.condmatl
Then I read this update/join cannot be used with an oracle server
Any suggestions?
Hello
Here's a way you can use the MERGE:
MERGE INTO dst conductorinfo
With the HELP of calkva CBC
WE (dst.condsize = src.condsize
AND dst.condmatl = src.condmatl
)
WHEN MATCHED THEN UPDATE
SET dst.calkva = dst.calculatedkva
;
-
Joining several tables in Oracle DB
I have the following tables.
1 AddProject
-PROJID
-projName
2 AddLab
-Labrador
-teacher
3 ProjLabAssociation
-PROJID
-Labrador
4 AddResearchArea
-raID
-raName
5 ProjRAAssociation
-PROJID
-raID
AddProject is associated with tables-AddLab and AddResearchArea
ProjLabAssociation and ProjRAAssociation are the association of the tables that contain the primary key of the corresponding tables. The two fields in these 2 tables are primary keys.
If AddProject has 3 entrances - (Proj1, ProjectA) (Proj2 ProjectB), (Proj3, ProjectC)
AddLab has 2 entrances - (Lab1, Bangalore), (Lab2, Chennai)
AddResearchArea has 2 inputs - AM1 (Green Computing) (RA2, Cloud Computing)
ProjLabAssociation has 2 entrances - (Proj2 Lab1), (Proj3, Lab1)
ProjRAAssociation has 3 entries - (Proj2 RA1), (Proj3, AM1), (Proj3, RA2)
If I ask by AddLab given for (Lab1, Bangalore), I should get the following columns in the result table
--------------------------------------------------------------------------------------------------------------------------------
Table2ID | Table2Name | Table3ID | Table3Name | Table1ID | Table1Name
Lab1. Bangalore | RA1 | Green Computing | Proj2 | Project b
Lab1. Bangalore | RA1 | Green Computing | Proj3 | Project c
Lab1. Bangalore | RA2 | Cloud Computing | Proj3 | Project c
--------------------------------------------------------------------------------------------------------------------------------
I tried the following commands but I m getting the expected result
1.
A SQLException exception is thrown by saying - java.sql.SQLException: ORA-01417: a table can be external joined as another tableSELECT * FROM AddLab al, ProjLabAssociation pl, AddProject ap WHERE al.labID = pl.labID(+) and ap.projID = pl.projID(+);
--------------------------------------------------------------------------------------------------------------------------------
2.
I do not get results expcted hereSELECT * FROM AddLab,AddProject,AddResearchArea WHERE labID in (select al.labID from ProjLabAssociation pl,AddLab al where al.labID = pl.labID) AND projID in (select ap.projID from ProjLabAssociation pl,Addproject ap where ap.projID = pl.projID) AND themeID in (select ar.raID from ProjRAAssociation pr, AddResearchArea ar where ar.raID = pr.raID) AND projID in (select ap.projID from ProjRAAssociation pr,Addproject ap where ap.projID = pr.projID) ORDER BY labID;
--------------------------------------------------------------------------------------------------------------------------------
Oracle version: 9i 10g / 11g
Can anyone help me in this.
Published by: user9205634 on December 22, 2011 03:40Hello
Below the code gives the result
with table1 as ( select 'Proj1' as table1id,'ProjectA' as table1name from dual union all select 'Proj2' as table1id,'ProjectB' as table1name from dual union all select 'Proj3' as table1id,'ProjectC' as table1name from dual union all select 'Proj4' as table1id,'ProjectD' as table1name from dual ) ,table2 as ( select 'Lab1' as table2id,'Bangalore' as table2name from dual union all select 'Lab2' as table2id,'Chennai' as table2name from dual union all select 'Lab3' as table2id,'Delhi' as table2name from dual ) , table3 as ( select 'RA1' as table3id,'Green Computing' as table3name from dual union all select 'RA2' as table3id,'Cloud Computing' as table3name from dual ) ,table1table2 as ( select 'Proj2' as table1id,'Lab1' as table2id from dual union all select 'Proj3' as table1id,'Lab1' as table2id from dual union all select 'Proj3' as table1id,'Lab2' as table2id from dual union all select 'Proj4' as table1id,'Lab3' as table2id from dual ) ,table1table3 as ( select 'Proj2' as table1id,'RA1' as table3id from dual union all select 'Proj3' as table1id,'RA1' as table3id from dual union all select 'Proj3' as table1id,'RA2' as table3id from dual ) select t2.table2id,t2.table2name,t3.table3id,t3.table3name,t1.table1id,t1.table1name from table1 t1,table2 t2,table3 t3,table1table2 jt1t2,table1table3 jt1t3 where jt1t2.table2id=t2.table2id and t1.table1id=jt1t2.table1id and jt1t3.table1id(+)=jt1t2.table1id and t3.table3id(+)=jt1t3.table3id order by t2.table2name,t3.table3id;
TABLE2ID TABLE2NAME TABLE3ID TABLE3NAME TABLE1ID TABLE1NAME -------- ---------- -------- --------------- -------- ---------- Lab1 Bangalore RA1 Green Computing Proj2 ProjectB Lab1 Bangalore RA1 Green Computing Proj3 ProjectC Lab1 Bangalore RA2 Cloud Computing Proj3 ProjectC Lab2 Chennai RA1 Green Computing Proj3 ProjectC Lab2 Chennai RA2 Cloud Computing Proj3 ProjectC Lab3 Delhi Proj4 ProjectD 6 rows selected
Kind regards
Prabhu -
ANSI join kick off session Oracle
Under query works fine in 11I instance but not in R12. If I remove the text "INNER JOIN" and "LEFT OUTER JOIN" and replace it with the old syntax, then it's job to join. Here join ANSI is used if confused about how convert ANSI join old syntax.
WITH mo_rsrv
AS (SELECT / * + materialize * /)
Mr.organization_id,
Mr.inventory_item_id,
Mr.subinventory_code,
WLP.attribute3 document_type,
Mr.locator_id,
Mr.demand_source_line_id,
Mr.demand_source_name,
Mr.attribute6,
SUM (primary_reservation_quantity)
primary_reservation_quantity
OF mtl_reservations m., wwt_lookups wlp
WHERE mr.demand_source_type_id = wlp.attribute2
AND wlp.lookup_type = 'XXXX '.
AND wlp.attribute1 = 'PO '.
Mr.organization_id GROUP,
Mr.inventory_item_id,
Mr.subinventory_code,
WLP.attribute3,
Mr.locator_id,
Mr.demand_source_line_id,
Mr.demand_source_name,
Mr.attribute6),
po_ship_rec
AS (SELECT polla.ship_to_organization_id,
Polla.po_header_id,
Polla.po_line_id,
SUM (polla.quantity - NVL (polla.quantity_cancelled, 0))
quantity
OF apps.po_line_locations_all polla
-WHERE po_header_id = 191275
Polla.ship_to_organization_id GROUP,
Polla.po_header_id,
Polla.po_line_id)
SELECT "PO" document_type,
poha. Segment1,
Line_number, To_char (pola.line_num),
Ship_set NULL,
Msik.concatenated_segments ordered_item,
Pola.attribute4 config,
Pola.attribute14 material_designator,
Pola.CREATION_DATE needby_date,
po_ship_rec. Quantity,
mo_rsrv.primary_reservation_quantity,
"reservation_status,.
"total_onhand,.
poha.po_header_id,
Pola.po_line_id,
po_ship_rec.ship_to_organization_id,
Pola.item_id,
Ship_set_id TO_NUMBER (NULL),
Top_model_id TO_NUMBER (NULL),
Pola.last_update_date,
Pola.last_updated_by,
Pola.CREATION_DATE,
Pola.created_by
OF po_ship_rec
INNER JOIN apps.po_headers_all poha
WE (poha.po_header_id = po_ship_rec.po_header_id)
INNER JOIN apps.po_lines_all pola
WE (pola.po_line_id = po_ship_rec.po_line_id)
INNER JOIN apps.mtl_system_items_kfv reform
WE (msik.organization_id =
po_ship_rec.ship_to_organization_id
AND msik.inventory_item_id = pola.item_id)
LEFT OUTER JOIN mo_rsrv
WE (mo_rsrv.demand_source_name = poha.segment1
AND mo_rsrv.attribute6 = pola.po_line_id
AND mo_rsrv.organization_id =
po_ship_rec.ship_to_organization_id
AND mo_rsrv.inventory_item_id = pola.item_id)
WHERE 1 = 1;
Suspicion of MATERIALIZATION is undocumented and may cause errors, or bad results. Your query works if you remove the indicator?
SY.
-
During the week to Daily Record Explosion?
Hello
I'm looking for a way to take a set of documents stamped with a weekend date and explode in a recordset for each day of this week. The data of the entire file would be identical, except for the date column. Here is an example.
What I want on the other end is something like this (I'll do only the first two records from above). I put an asterisk on the 'source' folderitem_id week_end_date some_value 1 2009-12-05 5 1 2009-12-12 10 1 2009-12-19 15 2 2009-12-05 20 2 2009-12-12 25 2 2009-12-19 30
I know I could do with a PL/SQL loop, but I am interested in more than one pure solution of SQL.item_id week_end_date some_value 1 2009-11-29 5 1 2009-11-30 5 1 2009-12-01 5 1 2009-12-02 5 1 2009-12-03 5 1 2009-12-04 5 1 2009-12-05 5* 1 2009-12-06 10 1 2009-12-07 10 1 2009-12-08 10 1 2009-12-09 10 1 2009-12-10 10 1 2009-12-11 10 1 2009-12-12 10*
My thought was to do a temp of sorts with 7 rows table and a column. It would basically be numbers between 0 and -6. Then in my SQL I assemble and simply add the value of the temporary table to the week_end_date blew up the records on. I would like to know if I'm crazy or on the right track. If I'm heading in the right direction, I would need a little help with the implementation.
Thanks in advance.Hello
Welcome to the forum!
You have the right idea, with a table 7-row 1-column, but there is no need to create an actual table.
You can use a subquery, as cntr below, created within the application itself and then join the result set of the subquery as if it were a table:WITH cntr AS ( SELECT LEVEL - 1 AS n FROM dual CONNECT BY LEVEL <= 7 ) SELECT item_id , week_end_date - n AS a_date , some_value FROM table_x CROSS JOIN cntr ;
In Oracle, it is rarely necessary to create temporary tables.
-
Hello
I have the following data
create or replace view offdays as
(
Select 1 empid, to_date('23/01/2015','dd/mm/yyyy') dt, 1 offday for all double union
Select 2 empid, to_date('23/01/2015','dd/mm/yyyy') dt, 1 offday for all double union
Select 3 empid, to_date('21/01/2015','dd/mm/yyyy') dt, 1 double offday
);
create or replace view payrolldates as
(
Select to_date('21/01/2015','dd/mm/yyyy') as dt of union double all the
Select to_date('22/01/2015','dd/mm/yyyy') as dt of union double all the
Select to_date('23/01/2015','dd/mm/yyyy') as dt of union double all the
Select to_date('24/01/2015','dd/mm/yyyy') as dt of union double all the
Select to_date (' 25/01/2015 ',' dd/mm/yyyy') in the double dt
);
Select * from payrolldates and b offdays left outer join on b.dt order = b.empid a.dt, a.dt;
With the above query, I get after release
DATE
EMPID
OFF
23/01/2015
1
1
23/01/2015
2
1
21/01/2015
3
1
22/01/2015
< NULL >
< NULL >
24/01/2015
< NULL >
< NULL >
25/01/2015
< NULL >
< NULL >
But I need the output as follows
DATE
EMPID
OFF
21/01/2015
1
0
22/01/2015
1
0
23/01/2015
1
1
24/01/2015
1
0
25/01/2015
1
0
21/01/2015
2
0
22/01/2015
2
0
23/01/2015
2
1
24/01/2015
2
0
25/01/2015
2
0
21/01/2015
3
1
22/01/2015
3
0
23/01/2015
3
0
24/01/2015
3
0
25/01/2015
3
0
I use oracle 10 g.
Help, please
According to the power requested that each record in the view offdays should be repeated as many times as the number of records in the view of payrolldates-, this could be done via the cross join and a simple CASE statement to get an output of the column offday.
Select a.dt
empid
case when a.dt = b.dt
then offday
0 otherwise
end offday
of payrolldates one
offdays b
order of b.empid, a.dt;
-
Expected to a join behaviours?
Hello
formalities:
Select * from version of v$.
Oracle Database 11 g Enterprise Edition Release 11.2.0.3.0 - 64 bit Production
PL/SQL Release 11.2.0.3.0 - Production
CORE Production 11.2.0.3.0
AMT for 64-bit Windows: Version 11.2.0.3.0 - Production
NLSRTL Version 11.2.0.3.0 - Production
the question:
I was just wondering why this "join" between A and B do not work. A has no lines, B a 1 row
> my first answer... it should give 1 rank...
but alas... it doesn't!
the original request:
SELECT A.*, B.*, CASE WHEN A.METH = 'PAL' THEN '1' ELSE A.CFGNR_OFRESTPAL END VWNR_OFRESTPAL FROM CDCROBOTVERDICHTLOCSTATVW A, CDCVERDICHTSETTINGSVW B
> No rows returned
so I checked the counts:
Select count (*) in the CDCROBOTVERDICHTLOCSTATVW A;
0
Select count (*) in the CDCVERDICHTSETTINGSVW B;
1
Hmmm... very strange
so I ran a few tests more:
SELECT A.*, B.*, CASE WHEN A.METH = 'PAL' THEN '1' ELSE A.CFGNR_OFRESTPAL END VWNR_OFRESTPAL FROM CDCVERDICHTSETTINGSVW B , CDCROBOTVERDICHTLOCSTATVW A
> no line
SELECT A.*, B.*, CASE WHEN A.METH = 'PAL' THEN '1' ELSE A.CFGNR_OFRESTPAL END VWNR_OFRESTPAL FROM CDCVERDICHTSETTINGSVW B cross join CDCROBOTVERDICHTLOCSTATVW A
> no line
SELECT A.*, B.*, CASE WHEN A.METH = 'PAL' THEN '1' ELSE A.CFGNR_OFRESTPAL END VWNR_OFRESTPAL FROM CDCVERDICHTSETTINGSVW B full outer join CDCROBOTVERDICHTLOCSTATVW A on 1 =1
> This returns the line from B correctly
ARTNR PROJECTNR VARIANT PROVIDER QMAX PRIO METH PALLETS SOMQTY FULLPALS RESTQTY RESTPALS CFGNR_OFRESTPAL FREELOCS DUMMYRECIP GEEN_VERDICHTING MAXSRCPALS MAXOPENPICKSETS NR_OF_RESTPAL ORDTYPE PRIO_ARTNR VERD_INRGRP VWNR_OFRESTPAL VERDICHT 11 4 3 VERDICHT QSE00918CLL80 CDCROB SELECT A.*, B.*, CASE WHEN A.METH = 'PAL' THEN '1' ELSE A.CFGNR_OFRESTPAL END VWNR_OFRESTPAL FROM CDCVERDICHTSETTINGSVW B left join CDCROBOTVERDICHTLOCSTATVW A on 1 = 1
> it is also returns the same rank B
Does anyone have an idea on how to fix this... or where to look to fix this?
This is a cross join. It is a Cartesian product. If there are no rows in a table, then you get no rows in the result.
SQL> with a as (select 1 x from dual), b as (select 1 y from dual where 1=0) 2 select a.*, b.* 3 from a, b; no rows selected
A left or right, or full outer join is apparently what you wanted.
Maybe you are looking for
-
Outlook 2007: Sender email response does not appear on my mail message
I don't know where this slots but if someone can help me... I use Outlook 2007 and before that 2003, with one e-mail account I have the problem that the sender's response appears not on my mail message. He only hows my origanal mail, if I answered an
-
Qosmio G20-115 - can't seem to run the BIOS update
I have a Qosmio G20-115, which I'm trying to run an update of the BIOS on because what he s not recognizing nor charge the battery, it s give an error message: The Ac adapter is not connected, or not enough battery power. What can I do to run the BIO
-
I CAN'T DO FILE/PRINTER SHARING. I GET a MESSAGE SHOW "SERVER SERVICE NOT STARTED" I ALSO TRIED WINDOWS HELP AND IT SAYS HELP AND SUPPORT NOT START. HOW CAN I GET THESE TO START AUTOMATIC
-
I can't add a printer, the printer queue is out how to activate it thank you for your help
-
delete the partition, volume disk empty retractable without data loss in Windows 7
When installed win 7 XP had disk c (everything on it) and F drive (empty). Need more space on the C drive. in disk management it says I can reduce F but it does not allow me to expand C. Can I delete this partition, or how to develop C? In f, he