connect before between two tables
I have this table structure
I have what it takes to return the value on prior connection
create table OBJECT_LIST ( cal_objid NUMBER(4) not null, obj_name VARCHAR2(100), obj_type VARCHAR2(20), obj_title VARCHAR2(20), description VARCHAR2(50) ); alter table OBJECT_LIST add constraint OBJECT_LIST_PK primary key (CAL_OBJID); create table CAL_ERD ( obj_child NUMBER(5) not null, obj_parent NUMBER(5) not null, obj_rel_type VARCHAR2(50) ); alter table CAL_ERD add constraint CAL_ERD_PK primary key (OBJ_CHILD, OBJ_PARENT); alter table CAL_erd add constraint cal_parent_FK foreign key (obj_parent) references object_list (CAL_objid); alter table CAL_erd add constraint cal_child_FK foreign key (obj_child) references object_list (cal_objid); insert into object_list (cal_objid, obj_name, obj_type) values(1192, 'MainObject', 'Form'); insert into object_list (cal_objid, obj_name, obj_type) values(1193, 'SecondObject', 'Form'); insert into object_list (cal_objid, obj_name, obj_type) values(1194, 'ThirdObject', 'Form'); insert into object_list (cal_objid, obj_name, obj_type) values(1195, 'FourthObject', 'Form'); insert into object_list (cal_objid, obj_name, obj_type) values(1196, 'FirthObject', 'Form'); insert into cal_erd values(1193,1192,null); insert into cal_erd values(1194,1193,null); insert into cal_erd values(1195,1194,null);
in the first table values
CAL_OBJID OBJ_NAME, OBJ_TYPE OBJ_TITLE DESCRIPTION
1192 MainObject form
1193 SecondObject form
1194 ThirdObject form
1195 FourthObject form
1196 FirthObject form
the second value of the table
OBJ_CHILD OBJ_PARENT OBJ_REL_TYPE
1192 1193
1194 1193
1195 1194
SQL script that I am trying
WITH t AS (SELECT li.obj_name, li.obj_type, li.obj_title, li.DESCRIPTION, LEVEL AS lvl, SYS_CONNECT_BY_PATH(li.obj_name, '/')paths FROM object_list li,cal_erd er where li.cal_objid = er.obj_parent(+) START WITH obj_parent IS NULL CONNECT BY NOCYCLE PRIOR obj_child = obj_parent) SELECT obj_name, LEAD(obj_name) OVER(ORDER BY paths) AS child_name, obj_type , obj_title , DESCRIPTION , substr(paths, INSTR(paths, '/', 1, CASE WHEN lvl > 1 THEN lvl-1 END) + 1 , INSTR(paths, '/', 1, CASE WHEN lvl > 1 THEN lvl END) - INSTR(paths, '/', 1, CASE WHEN lvl > 1 THEN lvl-1 END) - 1 ) AS parent_name FROM t;
get value
OBJ_NAME, OBJ_TYPE OBJ_TITLE DESCRIPTION PARENT_NAME CHILD_NAME
FirthObject FourthObject form
FourthObject form
I what like to be like that
OBJ_NAME, OBJ_TYPE DESCRIPTION OBJ_PARENT OBJ_TITLE OBJ_CHILD
SecondObject MainObject form
ThirdObject SecondObject form MainObject
fourthObject ThirdObject shape SecondObject
I would like if possible show the id of ojb_name
Hello
Here's a way to achieve the expected results, you want to:
WITH t AS (SELECT obj_parent , li.obj_name , li.obj_type , li.obj_title , li.DESCRIPTION , LEVEL AS lvl , SYS_CONNECT_BY_PATH(li.obj_name, '/')paths FROM object_list li LEFT JOIN cal_erd er ON (li.cal_objid = er.obj_child) START WITH obj_parent IS NULL CONNECT BY NOCYCLE PRIOR cal_objid = obj_parent), t2 AS ( SELECT LEAD(obj_name) OVER(PARTITION BY substr(paths, 1 , CASE WHEN INSTR(paths, '/', 1, 2)> 0 THEN INSTR(paths, '/', 1, 2)-1 ELSE LENGTH(paths) END) ORDER BY paths) AS child_name , obj_name , obj_type , obj_title , DESCRIPTION , substr(paths, INSTR(paths, '/', 1, CASE WHEN lvl > 1 THEN lvl-1 END) + 1 , INSTR(paths, '/', 1, CASE WHEN lvl > 1 THEN lvl END) - INSTR(paths, '/', 1, CASE WHEN lvl > 1 THEN lvl-1 END) - 1 ) AS parent_name FROM t) SELECT * FROM t2 WHERE child_name IS NOT NULL;
Result:
CHILD_NAME OBJ_NAME, OBJ_TYPE OBJ_TITLE PARENT_NAME DESCRIPTION
SecondObject MainObject form
ThirdObject SecondObject form MainObject
FourthObject ThirdObject shape SecondObject
Kind regards
Steve
Tags: Database
Similar Questions
-
I got a prob while creating a link/link between two tables in a jdeveloper11g
Hi guys...
I got a prob while creating a link/link between two tables in a jdeveloper11g, help me.
I use two table employee, Department.
Unfortunately there is no primary key and foreign key in these tables.now i updated on those of table structure.
I want to create a form like it should be a link between the Department data, i.e. data and employee while the Department is changed then only present corresponding employees in this block...
Table structure as follows
Employee:
-------------------
employe_id,
name,
Department,
GR,
Date of birth
Department of justice
Department:
--------------------
department_id,
department_name;
Note: in the employee department table is the same as in the department table department_id...
So, you want to build master / detail between Department & sub_departments?
In the same way, create a new, yet another link between departments & sub_departments, so that the connection is:
Department.Department_Id = sub_departments.department_id
-
I need to implement Drag N Drop between two tables that saves the two records
I need to implement Drag N Drop between two tables that saves the two records on a third page, using drag 'n drop.Check out this video http://baigsorcl.blogspot.com/2011/01/drag-and-drop-collection-in-oracle-adf.html
-
two relationships between two tables
Hi all
I created a cube in my db (using OWB) of two relationships to my time dimension. A relationship shows the start time of a process, that the other represents the date of termination or end.
example of the cube:
Fact1
Fact2
Dim_Time1
Dim_Time2
where Dim_time1 and Dim_Time2 link to the same dimension.
Unfortunately I have trouble this manually import in obiee administrator. I imported the fact table and the dimension of the physical layer table. Can I move to the business layer and create the two joins between two tables. But the overall consistency check up a mistake, I shouldn't have two relationships between two tables and remove a foreign key.
What I am doing wrong?
Kind regards
KnutKnut,
In your example, you should have a time dimension in the phyiscal layer and alias of this 2 x, for Dim_time1 and for Dim_time2, in this way aliases are separate tables as the BI server point of view and you define releations separate on the same table, you can define specific to each alias dim relevant time joins.
In this way, you will have two time decreases intensity in MDB layer also, has 'Dim-Start Time' and a ' Sun - term time "or similar.
Hope this helps,
Alastair -
Use a where clause clause if there is a relationship between two tables
Is it possible to use a where clause clause if there is a relationship between two tables.
I have a relationship between two tables:
And a.customer = b.customer (+)
If b.customer exists in a.customer I would add this in where clause
And b.info = 'X '.
But how?It's the outer joins by chance?
If so, why not just:
and b.customer(+) = a.customer and b.info(+) = 'X'
BTW, I put the two "b" on the left column to make it easier to read. Some people mix that makes me crazy, but makes no difference to the query.
-
How to remove the extra space between two Table HTML
Hello
I wrote a code for printing costs. But there is more space between two Table Html, how I can remove it.
Please run that Code
Start
HTP.p (')
< html >
(< body > ');
HTP.p (')
< TABLE align = "left" width = "500" cellspacing = "0" cellpadding = "0" border = "1" >
< tr > < td align = 'right' white-space: nowrap; > Ph-2201751 < table >
< td > < table >
< /tr >
< tr > < td align = "center" white-space: nowrap; > < B > < table > < /B > SATYAM MODERN PUBLIC SCHOOL
< td > < table >
< /tr >
< b >
< td align = "center" white-space: nowrap; > < i > < H3 > (AFFILIATED to THE CBSC, NEW DELHI CODE No. 53544) < / H3 > < /I > < table >
< td > < table >
< /tr >
< tr > < td align = "center" white-space: nowrap; > new colony Braham, - 131001 (h) < table >
< td > < table >
< /tr >
< tr > < td align = "center" white-space: nowrap; > RECEPTION COSTS < table >
< td > < table >
< /tr >
< /table >
< TABLE width = "500" cellspacing = "0" cellpadding = "0" border = "1" >
< b >
< td width = "100" white-space: nowrap; > receipt no.: < table >
< td width = "100" white-space: nowrap; > Date received: < table >
< /tr >
< b >
< td width = "100" white-space: nowrap; > name: < table >
< td width = "100" white-space: nowrap; > father name: < table >
< /tr >
< b >
< td width = "100" white-space: nowrap; > class & s: < table >
< td width = "100" white-space: nowrap; > A/C No. : < table >
< /tr >
< b >
< td width = "100" white-space: nowrap; > from: < table >
< td width = "100" white-space: nowrap; > to: < table >
< /tr >
(< /table > ');
HTP.p (')
< / body >
(< / html > ');
end;
Thank you
EdHello
HTML is valid, that your code print?
Wouldn't be as below?
BR, Jari
Published by: jarola on December 18, 2009 15:22
I test your code
http://Apex.Oracle.com/pls/OTN/f?p=40323:25
I can't see any extra space between the tablesCannot connect call between two SX20
Hello world
I've implemented two Cisco SX20 units at two sites. When you attempt to place the call between two units, it is unstable. In particular, sometimes the call is connected, sometimes, it is not connected even if ping, tracert are Ok. It's very strange. I'm sure that the SX20 unit works well. If I make a conclusion that there is a problem with my network but I don't exactly know why.
All the world is facing this problem before?
Dzung.
Hey yours,
Disable NAT if you do not use.
Also useful to configure QoS, check on your link packet loss and bandwidth.
Hello
I have two tables USERS and LISTS:
And I want that there is a comparison between these two tables executed when user table USERS connect to the application.
They must compare the columns between the SEXES and AGE and if some users have the same attributes in its ranks as in a line in the table LISTS (here is unique each line) so that the user gets in his line in the column 'LIST_ID' the ID of the line with which attributes between GENDER and AGE.
Example:
USERS TABLE: exampleuser | Boby | McGrahem | Male | 18. -------
LISTS OF TABLE: 28 | examplelist | Male | 18
Once the Login of the user Boby gets in its ranks the ID = 28 because the SEX and AGE corresponds to the row of table LIST:
Result:
USERS TABLE: exampleuser | Boby | McGrahem | Male | 18. 28
CREATE TABLE "USERS" ( "USERNAME" VARCHAR2(15) NOT NULL ENABLE, "FORRNAME" VARCHAR2(15) NOT NULL ENABLE, "SURNAME" VARCHAR2(15) NOT NULL ENABLE, "GENDER" VARCHAR2(10) NOT NULL ENABLE, "AGE" NUMBER, "LIST_ID" NUMBER, CONSTRAINT " USERS_PK" PRIMARY KEY ("USERNAME") USING INDEX ENABLE
CREATE TABLE "LISTS" ( " LIST_ID" NUMBER NOT NULL ENABLE, " LISTNAME" VARCHAR2(50) NOT NULL ENABLE, "GENDER" VARCHAR2(10) NOT NULL ENABLE, "AGE" VARCHAR2(3) NOT NULL ENABLE, CONSTRAINT " LISTS_PK" PRIMARY KEY ("LIST_ID") USING INDEX ENABLE
I need help for coding this, if someone be so good.
This is my essay:
DECLARE v_listid varchar2(100); BEGIN SELECT LIST_ID into v_listgid FROM LISTS WHERE GENDER = (SELECT GENDER FROM USERS WHERE UPPER(TRIM(USERNAME)) = UPPER(TRIM(:APP_USER))) AND AGE = (SELECT AGE FROM USERS WHERE UPPER(TRIM(USERNAME)) = UPPER(TRIM(:APP_USER))); UPDATE USERS SET LIST_ID = v_listid WHERE UPPER(TRIM(USERNAME)) = UPPER(TRIM(:APP_USER)); END;
I'd like to REALLY shy away using the USER name as the primary key, because the fact that users can create duplicate user names... YOU should NEVER base a PK on the entry of user, the better to let the database create and maintain this element of date...
FIX:
UPDATE to users U
SET List_Id = (SELECT List_Id OF lists L WHERE L.Gender = U.Gender and L.SOMENUMBER = U.SOMENUMBER) AND
Upper (U.UserName) = UPPER(:APP_USER);
Don't really want to cut the strings, Oracle which will do since they are of type varchar2 columns...
Thank you
Tony Miller
Software LuvMuffin
Ruckersville, WILLConnectivity options between two Playbooks?
What are the options of connectivity between two Playbooks?
-What is BT pairing between possible?
-I guess if they are on the same subnet, you should be able to speak directly on Wifi?
You should definitely be able to talk directly between two PBs on the same wireless subnet. Note that at least in the AIR, UDP is not supported, then you are probably limited to the protocols built on TCP, for now. Find the other device is your main problem, but would work at the entrance of the user of an IP address, or something like QR codes.
I don't think we will have any BT support initially, but which should eventually be possible somehow.
We see interconnectivity NFC at some point, which would allow some ways ordained to share things.
In some simple cases, you can use the camera and a QR code, although I do not think THAT RIM has indicated any support in the short term for a barcode API so this would probably involve some third-party libraries.
If you wanted to get complicated, you can use the audio output on one and the MIC on the other. Which would also be you to make a "show" mode of communication, although humans nearby could get mad. (Probably the QR code approach allows a limited form of 'broadcast' as well).
I think that exhausts my supply of ideas for the moment.
The most elegant way to get the difference between two tables - not least!
Hello
Simplified example of what I'm trying to achieve - I have two tables ORIGINAL and REVISED.
My aim is to compare the two, such as; -
When there is data in the two tables I get the difference between the Budget column, and if there is no difference, so I don't want no lines.
When data exists in the ORIGINAL, but not in review, I want to the inverse of the current value of the Budget column.
Where the data exist in REVISED I want the REVISED value.
I can see how I can do this, see below, but is there a more elegant solution?
Data for the ORIGINAL table
Data for the REVISED tableselect '801040' entity, '2186' expense_type, 234000 budget from dual union all select '801040' entity, '3001' expense_type, 1000 budget from dual union all select '801040' entity, 'P132' expense_type, 34000 budget from dual union all select '801040' entity, 'P135' expense_type, 43000 budget from dual
Desired outputselect '801040' entity, '2186' expense_type, 235000 budget from dual union all select '801040' entity, 'P132' expense_type, 34000 budget from dual union all select '801040' entity, 'P139' expense_type, 56000 budget from dual
ENTITY EXPENSE_TYPE DIFFERENCE
------ ------------ ----------
801040 2186 1000
801040 3001-1000
801040 P135-43000
801040 P139 56000
5 selected lines.
Code current to achieve this, is there a better way?
Thanks a lot for your comments,.select original.entity , original.expense_type , (nvl(revised.budget,0) - original.budget) as difference from original , revised where original.entity = revised.entity(+) and original.expense_type = revised.expense_type(+) and (nvl(revised.budget,0) - original.budget) != 0 union all select revised.entity , revised.expense_type , revised.budget as difference from revised where not exists (select 'x' from original where original.entity = revised.entity and original.expense_type = revised.expense_type) and revised.budget != 0
Robert.
Published by: Robert Angel on January 17, 2012 03:31 to change is not equal to! = - Thanks for the heads upSQL> with original 2 as 3 ( 4 select '801040' entity, '2186' expense_type, 234000 budget 5 from dual 6 union all 7 select '801040' entity, '3001' expense_type, 1000 budget 8 from dual 9 union all 10 select '801040' entity, 'P132' expense_type, 34000 budget 11 from dual 12 union all 13 select '801040' entity, 'P135' expense_type, 43000 budget 14 from dual 15 ) 16 , revised 17 as 18 ( 19 select '801040' entity, '2186' expense_type, 235000 budget 20 from dual 21 union all 22 select '801040' entity, 'P132' expense_type, 34000 budget 23 from dual 24 union all 25 select '801040' entity, 'P139' expense_type, 56000 budget 26 from dual 27 ) 28 select * 29 from ( 30 select nvl(o.entity, r.entity) entity, 31 nvl(o.expense_type, r.expense_type) expense_type, 32 nvl(r.budget,0) - nvl(o.budget,0) budget 33 from original o 34 full join revised r 35 on o.entity = r.entity 36 and o.expense_type = r.expense_type 37 ) 38 where budget <> 0 39 / ENTITY EXPE BUDGET ------ ---- ---------- 801040 2186 1000 801040 P135 -43000 801040 3001 -1000 801040 P139 56000 SQL>
getting data between two tables
Hi everyone, I need help with a query that seems simple, but I can't understand. consider the following data.
with data as (
s élire 802 cd from dual union all
select 803 cd from dual union all
select 804 cd from dual
data2 as
( select 804 cd from dual )
I want to join the two tables so that the result will be as follows:
in the above data, we can see that 804 is common in both tables. in this case, the output should be 804.
Similarly, if 2 data include the following:
data2 as
( select 804 cd from dual union all
Select 803 cd from dual
)
the output is then 803 804.
Now consider the following data
with data as (
s élire 802 cd from dual union all
select 803 cd from dual union all
select 804 cd from dual
)
take data2 table is empty
I want to join the two tables, and in this case, the output should be 802,803,804. data2 table is empty, then the default behavior is to get all the data in the data table. Since there is no line that corresponds to rows in the data table,
the default behavior is to display output all data in the data table. in this case 802,803,804
can someone write a query for this?
Hello
elmasduro wrote:
Hi Frank, thanks for the request. These are very good questions. Here are the answers
What happens if data2 rows, but none of them match data CD?
It won't happen because the integrity of the data.
...
I see it; a data line 2 will be in the data. You have a FOREIGN KEY constraint, or something similar, so if cd = 804 exists in database2, then it must also exist in the data.
What happens if the data is empty and data2 is not?
If data is empty and data2 is not, then the data2 data should be released.
for example
with the data as)
data table is empty
data2 as
(select cd 804 Union double all the)
Select cd 805 double
)
When you join data and data2 account with the above data, then the output should be 804 805. data2 data should be the display if the data table is empty. ...
Doesn't that contradict what you said earlier? Previously, it seemed to say that each row of data2 will be in the data, but now you give an example where all data2 lines are not in the data.
If the first is true, then the solution in response #2 should work.
If the latter is true, you can change the query like this:
WITH got_r_num AS
(
SELECT NVL (d.cd, d2.cd) AS cd
DENSE_RANK () (ORDER IN CASE
WHEN d.cd IS NOT NULL
AND d2.cd IS NOT NULL
THEN "A".
WHEN d.cd IS NOT NULL
THEN 'B '.
ANOTHER 'C '.
END
) AS r_num
DATA d
FULL OUTER JOIN data2 d2 ON d.cd = d2.cd
)
SELECT cd
OF got_r_num
WHERE r_num = 1
ORDER BY cd
;
Difference between two tables (ORA-01722)
I am trying to get the difference of two tables on two databases.
Walker I run the script below, it gives me a result that is not accurate.
Select name, creation_time of v$datafile@REMOTE_database.com
However, when I run this script, I get an accurate count of the difference. How can I list the exact number instead of only to count the difference? Want lists all five name missing on table 2.
2 LESS THAN
3 select name, creation_time from v$ datafile;
I get 14 ranks of foregoing.
SQL > SELECT a.cnt - b.cnt
> count 2 (name) select cnt (of v$datafile@REMOTE_database.com) a, b3 (select count (name) NTC v$ datafile);
edited by: Albert Zaza on July 19, 2010 11:19
A.CNT - B. CNT
-----------
5have you tried:
select trim(upper(name)) from v$datafile@REMOTE_database.com MINUS select trim(upper(name)) from v$datafile;
Left join between two tables using two different conditions
I have following three tables with their data, as shown below.
CREATE TABLE TIREMASTERPROCESS_TEMP
(
PRODUCTIONCODE TANK (12 BYTES),
FIELDNAME CHAR (12 BYTES),
DATACHR VARCHAR2 (60 BYTE),
REVISIONNO TANK (3 BYTES),
DATANUM NUMBER (9.4)
)
Whether the table c. and its sample data are like
FIELDNAME DATACHR REVISIONNO DATANUM PRODUCTIONCODE
AB No. Nch 1 100 0
AB No. Nch 1 108 0
AB No.-of-Nch 1 1 0
Ass42 teased dishes 1 0
Ass42 BTDrumNo1 BTD-051 1 0
AB53 BTDrumNo1 BTD-051 104 0
CREATE TABLE materialcode
(
UPPERMATERIALCODE CHAR (20),
PROCESSNO TANK (3),
PROCESSADOPTDATE TANK (9)
)
Whether the table b. and its sample data are like
UPPERMATERIALCODE PROCESSNO PROCESSADOPTDATE
Ass42 1 20120717
AB53 108 20121121
111 20111104 AS05
104 20120928 AS30
CREATE TABLE BUILDINGSCHEDULEMASTER
(
BUILDINGSIZE TANK (5 BYTES),
GTCODE FLOAT (4 BYTES),
TIREPERCART NUMBER (3.0).
BUILDINGLOT NUMBER (3.0)
)
Whether table and its sample data are like
BUILDINGSIZE GTCODE TIREPERCART BUILDINGLOT
AB42A 4 12 ass42
AB53A 4 88 AB53
AS30A AS30 4 80
BF03A 1 90 BF03
Now, I need to get some data in these fields by using the suite of mappings.
« PR_ » || Trim (a.BUILDINGSIZE) | ' / MPL2' Processid,--PRIMARY KEY
TO_DATE (substr (NVL(b.PROCESSADOPTDATE,'19800101'), 7, 2) |) » /'|| SUBSTR (NVL(b.PROCESSADOPTDATE,'19800101'), 5, 2) | » /'|| SUBSTR (NVL(b.PROCESSADOPTDATE,'19800101'), 1, 4). (' 01:00:00 ',' dd-mm-yyyy hh24:mi:ss') starteff, to_date (SUBSTR (NVL(b.PROCESSADOPTDATE,'19800101'), 7, 2) |) » /'|| SUBSTR (NVL(b.PROCESSADOPTDATE,'19800101'), 5, 2) | » /'|| SUBSTR (NVL(b.PROCESSADOPTDATE,'19800101'), 1, 4). (' 01:00:00 ',' dd-mm-yyyy hh24:mi:ss') startDate.
b.PROCESSNO revisioncodeid,
a.BUILDINGLOT tirepercart ,
CASE WHEN c.FIELDNAME = 'BTDrumNo1' then c.DATACHR end drumtype1.
BOX WHEN (trim (C.DATACHR) = '1' and trim (C.FIELDNAME) = "No. Nch") and THEN click 'YES '.
ANOTHER 'NO '.
END may-BUG,
case
When c.FIELDNAME = 'Wavy'
AND c.DATACHR = 'Use' THEN on 'YES '.
When c.FIELDNAME = 'Wavy'
AND c.DATACHR <>'Use' THEN 'NO '.
fine wavy
Now for the tables A and B I have the simple join as condition
a.GTCODE = b.UPPERMATERIALCODE
But I have to use two different left join conditions to join the table B and C to calculate the RESP fields according to the condition.
Now, I have to use
(trim (b.UPPERMATERIALCODE)). » -'|| Trim (b.PROCESSNO) = Trim (c.PRODUCTIONCODE) | » -'|| Trim (c.REVISIONNO)
condition to get the data for the WAVY and DRUMTYPE1 fields.
But at the same time, I have to use
substr (Trim (b.UPPERMATERIALCODE), 1, 2). » -'|| Trim (b.PROCESSNO) = Trim (c.PRODUCTIONCODE) | » -'|| Trim (c.REVISIONNO)
conition to derive the CHAFER field.
And for this reason I am come so many duplicates and do not correct results for JUNEBUG, WAVY, DRUMTYPE1, and STARTDATE field.
I need some advice as how can I do so that I get the correct results without duplicates for the PRIMARY KEY.
Thank you
MaheshIt would have been easier to answer if you gave us your example query that gives incorrect results - which both show us what you are doing and give us a starting point.
Insert instructions for data, rather than only the data would have helped too, making it more quick to test this point.
You do not show what you have done with your two outer join criteria, but I think you need to list TIREMASTERPROCESS_TEMP in your query twice, with alias names. Here's what I did:select a.BUILDINGSIZE, a.GTCODE, b.PROCESSNO , c1.FIELDNAME, c1.DATACHR, C2.FIELDNAME, C2.DATACHR , CASE WHEN c1.FIELDNAME='BTDrumNo1' then c1.DATACHR end drumtype1 , CASE WHEN (trim(c2.DATACHR) = '1' and trim(c2.FIELDNAME) = 'No-of-Nch') THEN 'YES' ELSE 'NO' END CHAFER , case when c1.FIELDNAME='Wavy' AND c1.DATACHR='Use' THEN 'YES' when c1.FIELDNAME='Wavy' then 'NO' else null end wavy from BUILDINGSCHEDULEMASTER A join materialcode b on a.GTCODE=b.UPPERMATERIALCODE left outer join TIREMASTERPROCESS_TEMP c1 ON trim(b.UPPERMATERIALCODE)||'-'||trim(b.PROCESSNO) = trim(c1.PRODUCTIONCODE)||'-'||trim(c1.REVISIONNO) left outer join TIREMASTERPROCESS_TEMP c2 ON substr(trim(b.UPPERMATERIALCODE),1,2)||'-'||trim(b.PROCESSNO) = trim(c2.PRODUCTIONCODE)||'-'||trim(c2.REVISIONNO)
C1 is an alias for the TIREMASTERPROCESS_TEMP line which is necessary for drumtype1 and wavy, c2 is an alias for the TIREMASTERPROCESS_TEMP line required for JuneBug. There was some minor errors in your calculations of field I tried to correct.
The results are:
BUILD GTCO PRO FIELDNAME DATACHR FIELDNAME DATACHR DRUMTYPE1 CHA WAV ----- ---- --- ------------ ---------- ------------ ---------- ---------- --- --- AB53A AB53 108 No-of-Nch 1 YES AB42A AB42 1 BTDrumNo1 BTD-051 No-of-Nch 1 BTD-051 YES AB42A AB42 1 Wavy NotUse No-of-Nch 1 YES NO AS30A AS30 104 NO
Hope this helps,
DavidGeneration of permutations of data between two tables
Hello world
I was wondering if someone can help me with the problem am I facing the work.
Simply put, I'll just assume three tables (in reality there are more).
I have the following tables:
Employees
Jobs
Employee_Job_Ratings
Thus, the Employees table contains a list of employees, the table of jobs a list of jobs and table Employee_Job_Ratings considers a number that represents how "good" the employee is on a particular task.
I am trying to write a query that will determine the best way to assign people to the jobs team. That is to say. which combination gives the total utilization of skills. So, I have three jobs and three people like this:
So - as you can see above, I could assign the people to jobs in the following permutations:Job A B C Person 1 2 3 Ratings A/1: 4 A/2: 2 A/3: 4 B/1: 3 B/2: 1 B/3: 2 C/1: 2 C/2: 3 C/3: 4
But - I obviously want the best people on every job. It would be ridiculous for me to choose 5 on 3 because the total score of skills for the whole team's 7 vs 10.*1* A - 1 B - 2 C - 3 Total: 9 *2* A - 1 B - 3 C - 2 Total: 9 *3* B - 1 C - 2 A - 3 Total: 10 *4* B - 1 C - 3 A - 2 Total: 9 *5* C - 1 A - 2 B - 3 Total: 7 *6* C - 1 A - 3 B - 2 Total: 7
So what I actually want to do is work on all the possible combinations that I can have people on each heap, so I can do a SUM of their scores and actually give a 'score' for each combination. This will allow to see the best way to distribute the jobs within a team. That is to say, do what I did above, but automatically.
The above is a trivial example, but in reality, we have many teams with a lot of jobs in each team. This is currently done manually but I know that this can be done automatically - all data are in our database so it would be great to be able to tell users "it's your best strategy for workloads" or at least give them an idea. People in charge of this planning can not use that told them the system, but it allows them to get at least an idea.
I'm fine with everything above independently to obtain permutations in lines, that is to say, tables A and B with three lines each, make out the six possible combinations. A Cartesian join, unfortunately, is not doing the job.
A person will only ever assigned to a single job.
I know it's a big ask and I apologize for not providing any code that I wrote myself, but unfortunately the first step I'm stuck - once I've done then I will be hopefully good! :) It is not as simple as just put a person with a level 4 on a job because they could be one 3 on another, then everyone is a 1 and so they would be better used on this other employment (that is to say on a job level 3 instead of a 4 level).
See you soon,./ dev/null wrote:
Hello
Thanks for the quick response. I use a 10g database. I tried using eval_number but get the following error (even when selecting just to double):ORA-37002: Oracle OLAP failed to initialize. Please contact Oracle OLAP technical support. ORA-33262: Analytic workspace EXPRESS does not exist. ORA-06512: at "SYS.DBMS_AW", line 203 ORA-06512: at "SYS.DBMS_AW", line 212
It is difficult to suggest what you can do differently when I don't know what you're doing.
Post a full script (including the CREATION of a PACKAGE or CREATE FUCNTION, as well as the request) that recreates the problem.Here are the test data, I use:...
Thank you; This seems good.
If this I expect to get 18 rear ranks, group in six 'strategies '. It is possible that there are more people that jobs however, I will deal with that once I sorted it for the same numbers - I hope that the solution dimensionnera easily!
My output in the example above would be so I hope that something like this:
strategy person_id job_id rating 1 1 1 4 1 2 2 1 1 3 3 4 2 1 1 4 2 2 3 2 2 3 2 3 3 1 2 2 3 2 1 3 3 3 3 4 4 1 2 2 4 2 3 2 4 3 1 2 5 1 3 4 5 2 1 3 5 3 2 3 6 1 3 4 6 2 2 1 6 3 1 2
I hope that this example shows a little better?
Now I see!
The query I posted earlier discoveries strategy presenting the total highest. This isn't what you want.
You want all the possible strategies, regardless of their classification. Here's a way to do it:WITH got_job_num AS ( SELECT job_id , ROW_NUMBER () OVER (ORDER BY job_id) AS job_num , COUNT (*) OVER () AS job_cnt FROM xxjobs WHERE job_name IN ('Mechanic', 'Painter', 'Welder') ) , permutations AS ( SELECT SYS_CONNECT_BY_PATH (p.person_id, ', ') AS person_path , SYS_CONNECT_BY_PATH (r.rating, '+') AS rating_path FROM xxpeople p JOIN xxratings r ON p.person_id = r.person_id JOIN got_job_num j ON r.job_id = j.job_id WHERE LEVEL = j.job_cnt START WITH j.job_num = 1 CONNECT BY NOCYCLE j.job_num = PRIOR j.job_num + 1 ) SELECT DENSE_RANK () OVER (ORDER BY pe.person_path) AS strategy , REGEXP_SUBSTR ( pe.person_path , '[^ ,]+' , 1 , jn.job_num ) AS person_id , jn.job_id , REGEXP_SUBSTR ( pe.rating_path , '[^+]+' , 1 , jn.job_num ) AS rating FROM permutations pe CROSS JOIN got_job_num jn WHERE NOT REGEXP_LIKE ( pe.person_path || ',' , '( [^ ,]+,).*\1' ) ORDER BY strategy , person_id ;
Since you are not concerned with the total score, you don't have need eval_number, or something like that.
Aside from that, rhe subqueries got_job_num and permutations are wjhat I psoted yesterday, except that they use your actual column and table names. If you do not want to use the person_name, then the xxpeople table is not necessary at all in this problem, and you can remove it from permutations.
The main request is quite different.The above query will display all 6 strategies and number them 1 to 6. I guess that you really care what strategy gets what number. The above query uses = 4 strategy where you had strategy = 5 and vice versa. If it's a problem, I'm sure it can be fixed.
This is the result I get:STRATEGY PERSON_ID JOB_ID RATING -------- ---------- ---------- ---------- 1 1 1 4 1 2 2 1 1 3 3 4 2 1 1 4 2 2 3 2 2 3 2 3 3 1 2 2 3 2 1 3 3 3 3 4 4 1 3 4 4 2 1 3 4 3 2 3 5 1 2 2 5 2 3 2 5 3 1 2 6 1 3 4 6 2 2 1 6 3 1 2
Hello
I want to retrieve those records where full word of the 'text' column does not match with the word in the column 'object' of another table.
for example
for id 101 table abc, it contains the Word as "Air Blow" which is exactly with 101 id of table of bcd. I don't want the case
With abc as
(
Select 101 as id, "Air Blow" as double union text
Select 102, 'Air' Union double
Select 103, 'Sink' double union
Select 104, 'Air press' Union double
Select 105, 'Putting out fires' double
),
BCD as
(
Select 101 as id, "Air blown near the mount" as subject, 'WE' as a double union countries
Select 102, "Air breath seen here," 'China' of the double union
Select 103, 'Throughput', 'canada' to double union
Select 104, 'air pressure', 'UK' Union double
Select 105, 'Fire engine', 'Ubdy' from dual
)
Select * from abc, bcd
where abc.id = bcd.id
and upper (abc.text) <>(bcd.subject) upper
OUTPUT
ID TEXT ID_1 Object COUNTRY 102 Air blown 102 Blowing air saw China 103 Water flow 103 Water flow Canada 105 Putting out fires 105 Firefighter Ubdy Another corresponding original solution post results...
SQL > ed
A written file afiedt.buf1 with abc as)
2. Select 101 as id, "Air BLOW" as double union text
3. Select 102, 'Air' Union double
4. Select 103, 'Sink' double union
5. Select 104, 'Air press' Union double
6 select 105, 'Fire extinguish' from dual
7 ),
8 bcd as
9 (
10. Select 101 as id, "Air blown near the mount" as subject, 'WE' as a double union countries
11. Select 102, "Air breath seen here," 'China' of the double union
12. Select 103, 'Throughput', 'canada' to double union
13. Select 104, 'air pressure', 'UK' Union double
14 select 105, 'Fire engine', 'Ubdy' from dual
15)
16. Select *.
17 ABC join bcd on (abc.id = bcd.id)
18 * where no regexp_like (bcd.subject, abc.text, 'i')
SQL > /.
TEXT ID COUNTR OBJECT ID
---------- --------------- ---------- ----------------------- ------
102 air blowing here view China 102
103 103 water flow flow of water canada
Fire 105 105 fire Ubdy3 selected lines.
Maybe you are looking for
-
drive a shared lightning between two computers
What is the best way to streamline the process to have an imac and a MBP and want to change several final cut pro projects out of the same drive at the same time on two different computers.
-
LabVIEW crashes when connecting to NXT
Whenever I try to connect with the NXT LabVIEW, LabVIEW hangs... I have LabVIEW 2010 and 2011, and it worked until I installed 2011. Can that be my problem? Thank you so much in advance. Alex.
-
resize the text of the xy graph axis
Hello, I have a question about XY charts: I want to have both XY-graphs with identical sizes aligned perfectly to have a nice comparison of the separate sets of data without their trace on the same graph. However, I can't find out how to set the widt
-
Problem with the Flash drive on the computer.
My folders on my flash drives appear flash drives, however, show have some use. When used on another computer, they are perfect. What could be the problem?
-
Hello I'm trying to transfer a qt application for blackberry 10 for this I'll put the qt creator according to this document... http://developer.BlackBerry.com/native/documentation/BB10/qt_porting_tools.html When I put the qtversion in the version of