Problem joining tables; duplicate records
I have problems with my request. She joined essentially three tables. I am inside the environment of the Apex, but this problem is with my request. I have three tables:
JOBS
Job_Id PK
Job_Number
Goal
Title
JOB_BUNDLES
Job_Bundle_Id PK
Modification_Number
Justification
Job_Id FK
JOB_TASKS
Job_Task_Id
Sequence
Task_Id (values can be either 1,2,3,4,5 or 6)
Job_Bundle_Id FK
You can see the stream / connection between each table. A JOB can have several JOB_BUNDLES and one can JOB_BUNDLE have JOB_TASKS a lot. One-to-many relationships
My query now displays a report of JOB_BUNDLES for a given job, represented in the form:
SELECT Job_Bundle_Id, Modification_Number, Justification, Job_Id FROM JOB_BUNDLES JB WHERE JB.Job_Id = :P26_Job_Id
The page element, P26_Job_Id represents the Job_Id of the WORK of the table argument. That said, each record JOB_BUNDLE will have JOB_TASKS related records; more specifically, there will be at least a record where JOB. TASKS. Task_Id = 6. This happens only once. I can't get my information from the request that I submitted and the information from the table JOB_TASKS where the Task_Id = 6. I tried to add a JOIN and a WHERE clause, but I still get duplicate records. If anyone has some insight on this issue, it would be greatly appreciated. Thanks in advance.
What:
SQL > select b.*
2, (select t.sequence
job_tasks 3 t
4 where t.job_bundle_id = b.job_bundle_id
5 and t.task_id = 6
(6) seq
job_bundles 7 b
8 where b.job_id = 1;
JOB_BUNDLE_ID MODIFICATION_NUMBER JUSTIFICATION JOB_ID SEQ
------------- ------------------- ------------------------------ ---------- ----------
1 0 there is no justification 1 12
2 that 1 I'm just here for test 1
3 2 it's the third amendment 1 7
3 selected lines.
Tags: Database
Similar Questions
-
Matching records between 2 tables with duplicate records
Hi all
I need help in what follows.
I have 2 tables Received_bills and Send_bills.
-------------------------------------------------------
-The DOF for Table SEND_BILLS
--------------------------------------------------------
CREATE TABLE SEND_BILLS
(DATE OF "DATUM",
NUMBER OF "PAYMENT."
'CODE' VARCHAR2 (5 BYTE)
) ;
--------------------------------------------------------
-The DOF for Table RECEIVED_BILLS
--------------------------------------------------------
CREATE TABLE 'RECEIVED_BILLS '.
(DATE OF "DATUM",
NUMBER OF "PAYMENT."
'CODE' VARCHAR2 (5 BYTE),
VARCHAR2 (5 BYTE) 'STATUS' ) ;
INSERTION of REM in RECEIVED_BILLS
TOGETHER TO DEFINE
Insert. RECEIVED_BILLS (DATUM, PAYMENT, CODE, STATE) values (to_date('10-OCT-15','DD-MON-RR'), 19, 'A1', 'SUCCESS');
Insert into RECEIVED_BILLS (PAYMENT, CODE, DATE, STATUS) values (to_date('10-OCT-15','DD-MON-RR'), 'A5', 'SUCCESS', 25);
Insert into RECEIVED_BILLS (PAYMENT, CODE, DATE, STATUS) values (to_date('10-OCT-15','DD-MON-RR'), 47, 'A4', 'FAILED');
Insert into RECEIVED_BILLS (PAYMENT, CODE, DATE, STATUS) values (to_date('10-OCT-15','DD-MON-RR'), 19, 'A1', 'FAILED');
Insert into RECEIVED_BILLS (PAYMENT, CODE, DATE, STATUS) values (to_date('10-OCT-15','DD-MON-RR'), 19, 'A1', 'SUCCESS');
INSERTION of REM in SEND_BILLS
TOGETHER TO DEFINE
Insert into SEND_BILLS (DATUM, CODE) values (to_date('10-OCT-15','DD-MON-RR'), 19, 'A1');
Insert into SEND_BILLS (DATUM, CODE) values (to_date('10-OCT-15','DD-MON-RR'), 19, 'A1');
Insert into SEND_BILLS (DATUM, CODE) values (to_date('10-OCT-15','DD-MON-RR'), 19, 'A1');
Insert into SEND_BILLS (DATUM, CODE) values (to_date('10-OCT-15','DD-MON-RR'), 25, 'A5');
Insert into SEND_BILLS (DATUM, CODE) values (to_date('10-OCT-15','DD-MON-RR'), 47, 'A4');
Insert into SEND_BILLS (DATUM, CODE) values (to_date('09-OCT-15','DD-MON-RR'), 19, 'A8');
Insert into SEND_BILLS (DATUM, CODE) values (to_date('10-OCT-15','DD-MON-RR'), 20, 'A1');
Insert into SEND_BILLS (DATUM, CODE) values (to_date('10-OCT-15','DD-MON-RR'), 19, 'A1');
Insert into SEND_BILLS (DATUM, CODE) values (to_date('10-OCT-15','DD-MON-RR'), 25, 'A5');
Insert into SEND_BILLS (DATUM, CODE) values (to_date('10-OCT-15','DD-MON-RR'), 25, 'A5');
I match all records of send_bills and received_bills with a status of 'SUCCESS' There is no single column in the table.
Correspondence held payment of columns, the code and the scratch cards, but it may also duplicate records. But even if there are duplicates, I also need those records in the query results
the query I wrote is this:
SELECT SEND.*
REC received_bills, send_bills send
WHERE send.datum = rec.datum
AND send.payment = rec.payment
AND send.code = rec.code
AND 'rec.status =' SUCCESS
;
The query results give me this
OCTOBER 10, 15 19 A1 OCTOBER 10, 15 19 A1 OCTOBER 10, 15 19 A1 OCTOBER 10, 15 19 A1 OCTOBER 10, 15 19 A1 OCTOBER 10, 15 19 A1 OCTOBER 10, 15 25 A5 OCTOBER 10, 15 19 A1 OCTOBER 10, 15 19 A1 OCTOBER 10, 15 25 A5 The result of the correct application would be
OCTOBER 10, 15 19 A1 OCTOBER 10, 15 25 A5 OCTOBER 10, 15 19 A1 The select statement that I need I want to use a loop to insert records in another table.
Can someone help me please?
Thanks in advance.
Best regards
Caroline
Hi, Caroline.
Caroline wrote:
Hi all
I need help in what follows.
I have 2 tables Received_bills and Send_bills.
-------------------------------------------------------
-The DOF for Table SEND_BILLS
--------------------------------------------------------
CREATE TABLE SEND_BILLS
(DATE OF "DATUM",
NUMBER OF "PAYMENT."
'CODE' VARCHAR2 (5 BYTE)
) ;
--------------------------------------------------------
-The DOF for Table RECEIVED_BILLS
--------------------------------------------------------
CREATE TABLE 'RECEIVED_BILLS '.
(DATE OF "DATUM",
NUMBER OF "PAYMENT."
'CODE' VARCHAR2 (5 BYTE),
VARCHAR2 (5 BYTE) 'STATUS');
INSERTION of REM in RECEIVED_BILLS
TOGETHER TO DEFINE
Insert. RECEIVED_BILLS (DATUM, PAYMENT, CODE, STATE) values (to_date('10-OCT-15','DD-MON-RR'), 19, 'A1', 'SUCCESS');
Insert into RECEIVED_BILLS (PAYMENT, CODE, DATE, STATUS) values (to_date('10-OCT-15','DD-MON-RR'), 'A5', 'SUCCESS', 25);
Insert into RECEIVED_BILLS (PAYMENT, CODE, DATE, STATUS) values (to_date('10-OCT-15','DD-MON-RR'), 47, 'A4', 'FAILED');
Insert into RECEIVED_BILLS (PAYMENT, CODE, DATE, STATUS) values (to_date('10-OCT-15','DD-MON-RR'), 19, 'A1', 'FAILED');
Insert into RECEIVED_BILLS (PAYMENT, CODE, DATE, STATUS) values (to_date('10-OCT-15','DD-MON-RR'), 19, 'A1', 'SUCCESS');
INSERTION of REM in SEND_BILLS
TOGETHER TO DEFINE
Insert into SEND_BILLS (DATUM, CODE) values (to_date('10-OCT-15','DD-MON-RR'), 19, 'A1');
Insert into SEND_BILLS (DATUM, CODE) values (to_date('10-OCT-15','DD-MON-RR'), 19, 'A1');
Insert into SEND_BILLS (DATUM, CODE) values (to_date('10-OCT-15','DD-MON-RR'), 19, 'A1');
Insert into SEND_BILLS (DATUM, CODE) values (to_date('10-OCT-15','DD-MON-RR'), 25, 'A5');
Insert into SEND_BILLS (DATUM, CODE) values (to_date('10-OCT-15','DD-MON-RR'), 47, 'A4');
Insert into SEND_BILLS (DATUM, CODE) values (to_date('09-OCT-15','DD-MON-RR'), 19, 'A8');
Insert into SEND_BILLS (DATUM, CODE) values (to_date('10-OCT-15','DD-MON-RR'), 20, 'A1');
Insert into SEND_BILLS (DATUM, CODE) values (to_date('10-OCT-15','DD-MON-RR'), 19, 'A1');
Insert into SEND_BILLS (DATUM, CODE) values (to_date('10-OCT-15','DD-MON-RR'), 25, 'A5');
Insert into SEND_BILLS (DATUM, CODE) values (to_date('10-OCT-15','DD-MON-RR'), 25, 'A5');
I match all records of send_bills and received_bills with a status of 'SUCCESS' There is no single column in the table.
Correspondence held payment of columns, the code and the scratch cards, but it may also duplicate records. But even if there are duplicates, I also need those records in the query results
the query I wrote is this:
SELECT SEND.*
REC received_bills, send_bills send
WHERE send.datum = rec.datum
AND send.payment = rec.payment
AND send.code = rec.code
AND 'rec.status =' SUCCESS
;
The query results give me this
OCTOBER 10, 15 19 A1 OCTOBER 10, 15 19 A1 OCTOBER 10, 15 19 A1 OCTOBER 10, 15 19 A1 OCTOBER 10, 15 19 A1 OCTOBER 10, 15 19 A1 OCTOBER 10, 15 25 A5 OCTOBER 10, 15 19 A1 OCTOBER 10, 15 19 A1 OCTOBER 10, 15 25 A5 The result of the correct application would be
OCTOBER 10, 15 19 A1 OCTOBER 10, 15 25 A5 OCTOBER 10, 15 19 A1 The select statement that I need I want to use a loop to insert records in another table.
Can someone help me please?
Thanks in advance.
Best regards
Caroline
Want to get answers that work? Then make sure that the CREATE TABLE and INSERT statements you post too much work. Test (and, if necessary, correct) your statements before committing. You have a stray "." in the first INSERT statement for received_bills and receikved_bills.status is defined as VARCHAR2 (5), but all values are 6 characters long.
There are 5 lines in send_bills that are similar to the
10 OCTOBER 2015 19 A1
Why do you want that 2 rows like this in the output, not 1 or 3, or 4 or 5? Is it because there are 2 matching rows in received_bills? If so, you can do something like this:
WITH rec AS
(
SELECT the reference, payment, code
, ROW_NUMBER () OVER (PARTITION BY datum, payment, code)
ORDER BY NULL
) AS r_num
OF received_bills
Situation WHERE = 'SUCCESS'
)
send AS
(
SELECT the reference, payment, code
, ROW_NUMBER () OVER (PARTITION BY datum, payment, code)
ORDER BY NULL
) AS r_num
OF send_bills
)
SELECT send.datum, send.payment, send.code
REC, send
WHERE send.datum = rec.datum
AND send.payment = rec.payment
AND send.code = rec.code
AND send.r_num = rec.r_num
;
Note that the main request is very similar to the query you posted, but the last condition has changed.
If you need to insert these lines in another table, you can use this query in an INSERT statement. There is no need of a loop, or for any PL/SQL.
-
finding duplicate records in the DB table, or the data trasnpose
Hello
I have a question...
Key | UID. Start Dt | End date. / / DESC
--------------------------------------------------------------------------------
1. 101 | March 12 09 | 30 May 09 | UID101
2. 101 | January 1 09 | February 25 09 | UID101
3. 102. 13 March 09 | 30 March 09 | UID102
4. 103. 13 March 09 | 30 March 09 | UID103
5. 103. 13 March 09 | April 1 09 | UID103
6. 104. 13 March 09 | 30 May 09 | UID104
7. 104. February 25 09 | 29 May 09 | UID104
8. 105. 15 February 09 | March 1 09 | UID105
9. 105. April 1 09 | 30 May 09 | UID105
The query must know UID in duplicate according to the above data, which are stored in the same form in a table. The definition of the UID duplicate is
(1) UID repeating themselves (records by 2) ex are 101,103,104 and 105.
(2) each UID has two dates and date of end of beginning.
(3) the UID for which dates are overlaping. For ex: touch #4, 103 UID whose start dates are March 13 09-30-Mar-09 and there also another record, with the # 5 UID 103 key dates are 13 Mar 09 to 1 April 09. Here, there is overlap or intersection in line #4 with key #5 key dates dates of rank. This UID is duplicated UID by def.
What precedes that falls under def and selectable are 103 and 104 only 102 UID has only a single line, UID 105 dates are mutually exclusive or not that overlap and even for the UID.
Is there a function available DB to make use of?
Wanted not to delete records or duplicate records.
There is a report to display these duplicate records.
It would be good for me if I can get the data transposed for UID
as
Of
4. 103. 13 March 09 | 30 March 09 | UID103
5. 103. 13 March 09 | April 1 09 | UID103
TO
UID. Start the t1d. End t1d. Start the T2D. End T2D
103: |13-Mar-09|30-Mar-091-Apr-09 13 March 09
Any advice or ideas can be useful to gr8
Thank you...It can also be done without Analytics:
WITH test_data AS ( SELECT 1 AS KEY, 101 AS UD, TO_DATE('03/12/2009','MM/DD/YYYY') AS START_DT, TO_DATE('05/30/2009','MM/DD/YYYY') AS END_DT, 'UD101' AS DSC FROM DUAL UNION ALL SELECT 2 AS KEY, 101 AS UD, TO_DATE('01/01/2009','MM/DD/YYYY') AS START_DT, TO_DATE('02/25/2009','MM/DD/YYYY') AS END_DT, 'UD101' AS DSC FROM DUAL UNION ALL SELECT 3 AS KEY, 102 AS UD, TO_DATE('03/13/2009','MM/DD/YYYY') AS START_DT, TO_DATE('03/30/2009','MM/DD/YYYY') AS END_DT, 'UD102' AS DSC FROM DUAL UNION ALL SELECT 4 AS KEY, 103 AS UD, TO_DATE('03/13/2009','MM/DD/YYYY') AS START_DT, TO_DATE('03/30/2009','MM/DD/YYYY') AS END_DT, 'UD103' AS DSC FROM DUAL UNION ALL SELECT 5 AS KEY, 103 AS UD, TO_DATE('03/13/2009','MM/DD/YYYY') AS START_DT, TO_DATE('04/01/2009','MM/DD/YYYY') AS END_DT, 'UD103' AS DSC FROM DUAL UNION ALL SELECT 6 AS KEY, 104 AS UD, TO_DATE('03/13/2009','MM/DD/YYYY') AS START_DT, TO_DATE('05/30/2009','MM/DD/YYYY') AS END_DT, 'UD104' AS DSC FROM DUAL UNION ALL SELECT 7 AS KEY, 104 AS UD, TO_DATE('02/25/2009','MM/DD/YYYY') AS START_DT, TO_DATE('05/29/2009','MM/DD/YYYY') AS END_DT, 'UD104' AS DSC FROM DUAL UNION ALL SELECT 8 AS KEY, 105 AS UD, TO_DATE('02/15/2009','MM/DD/YYYY') AS START_DT, TO_DATE('03/01/2009','MM/DD/YYYY') AS END_DT, 'UD105' AS DSC FROM DUAL UNION ALL SELECT 9 AS KEY, 105 AS UD, TO_DATE('04/01/2009','MM/DD/YYYY') AS START_DT, TO_DATE('05/30/2009','MM/DD/YYYY') AS END_DT, 'UD105' AS DSC FROM DUAL ) select t1.ud, t1.key, t1.start_dt, t1.end_dt, t2.key, t2.start_dt, t2.end_dt from test_data t1 , test_data t2 where t1.ud = t2.ud and t1.key < t2.key and ((t1.end_dt - t1.start_dt) + (t2.end_dt - t2.start_dt)) > (greatest(t1.end_dt, t2.end_dt) - least(t1.start_dt, t2.start_dt)) /
Result:
UD KEY START_DT END_DT KEY START_DT END_DT ---------- ---------- ---------- ---------- ---------- ---------- ---------- 103 4 13-03-2009 30-03-2009 5 13-03-2009 01-04-2009 104 6 13-03-2009 30-05-2009 7 25-02-2009 29-05-2009
In addition, you will need to adjust the date a little comparison, depending on whether you set two periods where the first End_date is equal to the start_date in the second, because duplication or not.
Published by: tijmen on December 21, 2009 06:17
-
Hi gurus of the Oracle,.
Good morning/afternoon/evening!
There are several methods to effectively identify duplicate records. e.g. row_number() and group by, but all of these methods to highlight the duplicate record only. Which means that if your table has data such as
ID Name Room Date 1 ABC 203 20/07/2015 2 FGH 109 20/09/2015 3 HSF 202 20/08/2015 4 REF 201 20/08/2015 5 FGH 109 20/09/2015 6 HSF 291 24/08/2015 And I want to find duplicates based on name/room/day
Most of the queries will give me
Or the other
ID Name Room Date 5 FGH 109 20/09/2015 or
ID Name Room Date 2 FGH 109 20/09/2015
They don't give me two files unless I first do a group by (or Row_Number) in an internal query and then try to get the two lines in the outer query. In my view, should not be the way.
I need a report which highlights the two records only
ID Name Room Date 2 FGH 109 20/09/2015 5 FGH 109 20/09/2015 Hope that is clear.
Thanks in advance!
Hello
34MCA2K2 wrote:
Hi gurus of the Oracle,.
Good morning/afternoon/evening!
There are several methods to effectively identify duplicate records. e.g. row_number() and however all these methods to highlight only the duplicate of group by. Which means that if your table has data such as
ID Name Room Date 1 ABC 203 20/07/2015 2 FGH 109 20/09/2015 3 HSF 202 20/08/2015 4 REF 201 20/08/2015 5 FGH 109 20/09/2015 6 HSF 291 24/08/2015 And I want to find duplicates based on name/room/day
Most of the queries will give me
Or the other
ID Name Room Date 5 FGH 109 20/09/2015 or
ID Name Room Date 2 FGH 109 20/09/2015
They don't give me two files unless I first do a group by (or Row_Number) in an internal query and then try to get the two lines in the outer query. In my view, that shouldn't be the way...
Help the ROW_NUMBER analytic function, that you described is probably the easiest and most effective way to get the desired results.
You can do it without using any kind of subquery (for example, with a self-join or CONNECT BY), but which requires SELECT DISTINCT, which is inefficient.
-
Check duplicate record all by preventing insertion
Hello
I have a scenario where I need to insert records from 20 000 to 30 000 daily in a table that has data in millions.
Keep inserting a record in duplicate and in the event of any duplicate record, this issue need to be logged in another table.
I used FORALL except SAVE to allow loading of all records not not duplicate. But with this approach, I am unable to know which record was duplicate or problems in the insertion.
Also I can't use triggers to connect each record before insertion because I only need the duplicate records. Also, trigger will slow down performance.
Guide kindly on what approach I should follow to do this (which are also good performance as data are huge).
Kind regards
Karki
Logging error clause does not support dyrect path operations, you must remove the Add indicator to use.
This is because the logging of errors using autonomous transaction.
create table test_tomkt_raw (c1 varchar2(20), c2 varchar2(20), c3 varchar2(20)); Table created Executed in 0,015 seconds create table test_mkt (c1 varchar2(20), c2 varchar2(20), c3 varchar2(20)); Table created Executed in 0,031 seconds create table test_mkt_log (c1 varchar2(20), c2 varchar2(20), c3 varchar2(20)); Table created Executed in 0,078 seconds insert into test_tomkt_raw VALUES( 'A','B','C'); 1 row inserted Executed in 0,015 seconds insert into test_tomkt_raw VALUES( 'A','B','C'); 1 row inserted Executed in 0 seconds insert into test_tomkt_raw VALUES( 'D','E','F'); 1 row inserted Executed in 0 seconds insert into test_tomkt_raw VALUES( 'R','BD','AC'); 1 row inserted Executed in 0 seconds insert into test_tomkt_raw VALUES( 'AQ','SB','AC'); 1 row inserted Executed in 0,016 seconds insert into test_tomkt_raw VALUES( 'AA','BA','CA'); 1 row inserted Executed in 0 seconds insert into test_tomkt_raw VALUES( 'A','B','C'); 1 row inserted Executed in 0 seconds insert into test_tomkt_raw VALUES( 'D','E','F'); 1 row inserted Executed in 0,016 seconds ALTER TABLE test_mkt ADD PRIMARY KEY (C1,C2,C3); Table altered Executed in 0,015 seconds BEGIN DBMS_ERRLOG.CREATE_ERROR_LOG('test_mkt'); END; / PL/SQL procedure successfully completed Executed in 0,031 seconds INSERT /* APPEND */ INTO TEST_MKT SELECT * FROM TEST_TOMKT_RAW LOG ERRORS INTO ERR$_TEST_MKT ('TEST_01') --> This can be a variable on your code to identify this operation REJECT LIMIT UNLIMITED ; 5 rows inserted Executed in 0,063 seconds INSERT INTO test_mkt_log SELECT er.c1, er.c2, er.c3 FROM ERR$_TEST_MKT er WHERE er.ora_err_tag$ = 'TEST_01'--> This can be a variable on your code AND er.ora_err_number$ = 1 --> Unique constraint violated ; 3 rows inserted Executed in 0 seconds SELECT * FROM TEST_MKT ; C1 C2 C3 -------------------- -------------------- -------------------- A B C AA BA CA AQ SB AC D E F R BD AC Executed in 0,062 seconds SELECT * FROM TEST_MKT_LOG ; C1 C2 C3 -------------------- -------------------- -------------------- A B C A B C D E F Executed in 0,047 seconds DROP TABLE test_tomkt_raw; Table dropped Executed in 0,032 seconds DROP TABLE test_mkt; Table dropped Executed in 0,094 seconds DROP TABLE err$_test_mkt; Table dropped Executed in 0,078 seconds DROP TABLE test_mkt_log; Table dropped Executed in 0,047 seconds
-
update with the duplicate record
I'm working on my update page and I came across the problem where it allows to update the duplicate record. My code works for the second time when I tried to update the same name.
For example, I have the user name A, B and C of the database.
For the first time: update the username from B to A. This allowed me to do so given the A user name already in the table. (NOT RIGHT)
Second step: update the C to A user name. He stopped me because of the duplicate record
NOT QUITE RIGHT, IT SHOULD BE STOPPED ME FIRST?
Thank you
You should probably change the first query if a line with the same id is not considered:
Select user_name
users
where trim (user_name) = ' #trim (form.user_name) #
and user_id! = #user_id #.
If all the rows are returned from get_dupecheck then you don't want to do the update.
-
problems with table formatting
Hi all
I currently have problems with formatting or to use a table to record the data (well it will be saved in a .csv file, but I'm trying to use the table to get it all properly formatted to the .csv file for ease of reading). It is probably something easy I'm dominant or do not add. If someone with more knowledge of labview (I only worked a few months with her power) could guide me through the process of how to make my idea works, I would be very grateful.
I've attached the labview file, so you can see what I'm trying to do and how I'm trying to approach it a little more.
In addition, if you need a little more explanation, just ask.
Thank you very much!
At first glance, it seems that you have made more complicated it must be.
You have a ton of controls and indicators that could be better managed as tables or groups.
To your immediate problem of writing file, you could just build a digital table and then use the entry in the File.vi worksheet and select a comma as separator. The step where you are creating the spreadsheet string and then write in the text file is not necessary.
-
selection of the missing records between 2 duplicity without worrying about tables of records
Hi all
I have received_bills and send_bills of 2 tables.
The SEND_BILLS table is the source table displaying all records in it.
I need to compare two tables together and insert all the missing elements in received_items including duplicate records.
There may be duplicate in 2 tables records.
I wrote a query, but it does not select the duplicate records if it's all the 2 tables. When the same duplicate records are send_bills and received_bill without worrying because send_bills has 4 of them and received_bill 2, it does not select the other 2 duplicate records. And it's just what I need.
the query is
SELECT SEND. POINT OF REFERENCE,
Send. PAYMENT,
Send. CODE
OF SEND_BILLS SEND
WHERE THERE IS NOT (SELECT REC. DATUM, PAYMENT, REC. REC. CODE
OF RECEIVED_BILLS REC
WHERE REC. REFERENCE = SEND. SCRATCH CARDS
AND REC. PAYMENT = SEND. PAYMENT
AND REC. CODE = SEND. CODE)
send_bills records
OCTOBER 10, 15 19 A1 OCTOBER 10, 15 19 A1 OCTOBER 10, 15 19 A1 OCTOBER 10, 15 29 A3 OCTOBER 10, 15 47 A4 9 OCTOBER 15 19 A8 OCTOBER 10, 15 20 A1 OCTOBER 10, 15 19 A1 OCTOBER 10, 15 25 A5 OCTOBER 10, 15 25 A5 received_bills records
OCTOBER 10, 15 19 A1 OCTOBER 10, 15 29 A3 OCTOBER 10, 15 47 A4 OCTOBER 10, 15 19 A1 the result of the query is:
OCTOBER 10, 15 25 A5 OCTOBER 10, 15 25 A5 OCTOBER 10, 15 20 A1 9 OCTOBER 15 19 A8 So he selects all the records
the result should be
OCTOBER 10, 15 25 A5 OCTOBER 10, 15 25 A5 OCTOBER 10, 15 20 A1 9 OCTOBER 15 19 A8 OCTOBER 10, 15 19 A1 OCTOBER 10, 15 19 A1 --------------------------------------------------------
-The DOF for Table SEND_BILLS
--------------------------------------------------------
CREATE TABLE SEND_BILLS
(DATE OF "DATUM",
NUMBER OF "PAYMENT."
'CODE' VARCHAR2 (5 BYTE)
) ;
--------------------------------------------------------
-The DOF for Table RECEIVED_BILLS
--------------------------------------------------------
CREATE TABLE 'RECEIVED_BILLS '.
(DATE OF "DATUM",
NUMBER OF "PAYMENT."
'CODE' VARCHAR2 (5 BYTE)
) ;
-Insert the script for send_bills
Insert into SEND_BILLS (DATUM, CODE) values (to_date('10-OCT-15','DD-MON-RR'), 19, 'A1');
Insert into SEND_BILLS (DATUM, CODE) values (to_date('10-OCT-15','DD-MON-RR'), 19, 'A1');
Insert into SEND_BILLS (DATUM, CODE) values (to_date('10-OCT-15','DD-MON-RR'), 19, 'A1');
Insert into SEND_BILLS (DATUM, CODE) values (to_date('10-OCT-15','DD-MON-RR'), 29, 'A3');
Insert into SEND_BILLS (DATUM, CODE) values (to_date('10-OCT-15','DD-MON-RR'), 47, 'A4');
Insert into SEND_BILLS (DATUM, CODE) values (to_date('09-OCT-15','DD-MON-RR'), 19, 'A8');
Insert into SEND_BILLS (DATUM, CODE) values (to_date('10-OCT-15','DD-MON-RR'), 20, 'A1');
Insert into SEND_BILLS (DATUM, CODE) values (to_date('10-OCT-15','DD-MON-RR'), 19, 'A1');
Insert into SEND_BILLS (DATUM, CODE) values (to_date('10-OCT-15','DD-MON-RR'), 25, 'A5')
Insert into SEND_BILLS (DATUM, CODE) values (to_date('10-OCT-15','DD-MON-RR'), 25, 'A5')
-Insert invoices received from script
Insert into RECEIVED_BILLS (DATUM, CODE) values (to_date('10-OCT-15','DD-MON-RR'), 19, 'A1');
Insert into RECEIVED_BILLS (DATUM, CODE) values (to_date('10-OCT-15','DD-MON-RR'), 29, 'A3');
Insert into RECEIVED_BILLS (DATUM, CODE) values (to_date('10-OCT-15','DD-MON-RR'), 47, 'A4');
Insert into RECEIVED_BILLS (DATUM, CODE) values (to_date('10-OCT-15','DD-MON-RR'), 19, 'A1');
Can someone please help me with the query so that I can also select all the missing records, including duplicates.
Thanks in advance.
Best regards
Caroline
If you should by all means use loop and then (send_bills and received_bills contain the same data as your original post):
Select the reference, payment, code
of (with
Duplicator (Datum, Payment, code, CNT) as
(select the reference, code, payment, cnt - 1).
from (select datum, payment, code, count (one) - cnt count (two)
(select date, payment, code, 1 one, to_number (null) two)
of send_bills
Union of all the
Select datum, payment, code, to_number (null), 2 two
of received_bills
)
Reference group, code
having count (one)! = count (two)
)
Union of all the
Select the reference code, payment, cnt - 1
The duplicator
where cnt > 0
)
Select the reference, payment, code
The duplicator
)
DATUM PAYMENT CODE 10/09/2015 19 A8 10/10/2015 19 A1 10/10/2015 25 A5 10/10/2015 20 A1 10/10/2015 19 A1 10/10/2015 25 A5 Concerning
Etbin
-
APEX 5.0 Export to CSV produces duplicate records
Good day to you all:
I use APEX 5.0, and I have a classic report that has a total number of lines of 274. (274 documents also in SQL Developer). However, when I export the report to CSV, duplicate records are produced and the total number of lines increases to 365. Has anyone already known this before bug in APEX 5.0? I tried to reproduce the report to a type of interactive, but I get the same results when you export to CSV. Advice or guidance would be appreciated. Thank you.
Aqua
Hey Aqua,
If you are APEX 5.0.0 or 5.0.1? And which version of the database, you are on?
There was a problem with CLOB (which are used for the download) in 5.0.0 running on specific versions of 11 GR 2. A fix is included in the 5.0.1 patch set.
Concerning
Patrick
-
Miss an Interface if duplicate records present
Hi all
I'm using ODI 11 g.
I have the flat file interface table where I use IKM as control SQL added, check validation Option, Insert, separate and truncate option as TRUE, control flows as FALSE.
In my case, suppose I have 10 records out of these 2 records are duplicated. So my interface treats 8 discs to the next level.
But I want to the failure of the interface if there is duplicate records.
How to do this?
Thank you
LonyA set the primary key in the database or ODI?
Do it in the database if you wish to fail before inserting.
Do it in ODI and turn control static to true if you want to than his failure after insertion.Kind regards
JeromeFr -
Recover duplicate records.
CREATE TABLE TEST (TNO NUMBER (2), TNAME VARCHAR2 (10));
INSERT INTO TEST VALUES (1, 'TIGER');
INSERT INTO TEST VALUES (2, 'SCOTT');
INSERT INTO TEST VALUES (2, 'MILLER');
INSERT INTO TEST VALUES (2, 'JOHN');
INSERT INTO TEST VALUES (3, 'SMITH');
SELECT * FROM TEST;
NWT TNOM
----- ----------
1 TIGER
SCOTT 2
2 MILLER
2 JOHN
3 SMITH
power required:
NWT TNOM
----- ----------
SCOTT 2
2 MILLER
2 JOHN
I want duplicate records.Have you tried the forum search?
How recover duplicate records have been answered several times ;-)select tno, tname from ( select tno, tname, count(*) over (partition by tno) cnt from test ) where cnt > 1
-
Delete several duplicate records
Hi all
My table has multiple records, and I want to keep only the first record in the table. Can someone help me on this. I tried following things:
SELECT * FROM the tab
WHERE ROWID in (SELECT MAX (ROWID) <>
IN tab B
WHERE B.col1 = A.col1
AND B.col2 = A.col2
)
This remove the last duplicate record.
I also tried
SELECT * FROM the tab
WHERE ROWID > (SELECT MIN (ROWID)
IN tab B
WHERE B.col1 = A.col1
AND B.col2 = A.col2
)
This was removed and the first record to some places, but it has worked in some places. I am not able to understand why it was wrong in some places.
I'm working on Oracle 10 g
Please suggest.
Thank you.Duplicate records mean reproduce according to specific columns (in your example, col1 and col2).
If you want the trial to be held, you must determine all first according to what, if you mean the first entered record (which is not safe, and you should rely on an explicit column).
You can useSELECT * FROM tab A WHERE ROWID NOT IN (SELECT MIN (ROWID) FROM tab B WHERE B.col1 = A.col1 AND B.col2 = A.col2)
or use a column
SELECT * FROM tab A WHERE col3 NOT IN (SELECT MIN (col3) FROM tab B WHERE B.col1 = A.col1 AND B.col2 = A.col2)
Saad,
-
How to delete duplicate records
Suppose I have a table with N columns and K TAB (K < N) for which I should not have duplicated (in other words, the K column can be a key primary candidated)
Can you give me a SQL query to delete duplicate records of TAB for columns K?
Thank you very much!remove the tab where rowid not in (select min (rowid) of the TAB group by k)
-
How do I display values skyrocket in the IR filter for the joined table columns?
Hello
I have a problem in the IR the query is based on a table, joined with other tables. I would like to provide users the ability to use IR filter search bar in the joined table columns. The problem facing on this filter, the Expression field, by pressing the arrow button displays values for the fields in the primary table, but not for fields that come from joined tables. Have you experienced this behavior in your reports? Is this normal?
TIAHello
Correlated subqueries can improve performance - but it does not depend on the involved tables, the number of columns and the existence of indices. As far as I know, the optimizer has problems with them. You could try to explain the Plans on the two statements to verify that.
In any case, I created a new test page with the SQL for IR:
SELECT E.EMPNO, E.ENAME, D.DEPTNO, D.DNAME, E2.EMPNO "EMPNO2", E2.ENAME "ENAME2" FROM EMP E, EMP2 E2, DEPT D WHERE E.EMPNO = E2.EMPNO(+) AND E.DEPTNO = D.DEPTNO(+) AND E2.PRIMARY_EMPLOYEE(+) = 'Y'
http://Apex.Oracle.com/pls/OTN/f?p=267:226
As far as I can see, it works properly - except that if I do a filter on the ename column, when I try to create a second filter, drop-down lists ename all the values, while the other columns list only the available values after having applied the first filter. Which seems strange that the filters are applied as ANDS. But it does the same thing for other areas - IE, the field used in a filter is not filtered for the second filter - so I guess this is normal, but only a person in Apex could probably explain why it is so.
Otherwise, everything seems to work as I expect and the above page works the same as my test page, which uses external joins http://apex.oracle.com/pls/otn/f?p=267:224
Andy
-
"Compression" duplicate records over time
Hi, I've been fighting with a problem for a while now and don't know how to solve. I have data that looks like this:
Code1... Code2... Start_Dt... End_Dt
A.......... A......... 1/1/2000...12/31/2000
A.......... A......... 1/1/2001...12/31/2001
A.......... B......... 1/1/2002...12/31/2002
A.......... B......... 1/1/2003...12/31/2003
A.......... A......... 1/1/2004...12/31/2004
A.......... A......... 1/1/2005...12/31/2005
A.......... A......... 1/1/2006...12/31/2006
What I would do in the data store is 'compress' duplicate records, so that the final result should look like this:
Code1... Code2... Start_Dt... End_Dt
A.......... A......... 1/1/2000...12/31/2001
A.......... A......... 1/1/2002...12/31/2003
A.......... B......... 1/1/2004...12/31/2006
I can't figure a way to do it. I can just say:
Select code1, code2, min (start_dt), max (end_dt)
because I get A codes / has, from 01/01/2000 through 12/31/2006 - is not just, they have changed between the two.
Does anyone know of a way to do this (base mode GAME please... not to write PL/SQL and do a rank at a time).
Thanks in advance,
ScottHi Scott,.
Try this SQLselect a_code,b_code,group_id,min(start_date,max(end_date) from (select q.*,sum(change_flag) over (partition by a_code,b_code) group_id from (SELECT a_code, b_code, start_date, end_date, CASE WHEN a_code = lag(a_code,1) over (partition by a_code,b_code ORDER BY start_date) AND b_code = lag(b_code,1) over (partition by a_code,b_code ORDER BY start_date) THEN 0 ELSE 1 END change_flag FROM stp_test) q ) q2 group a_code,b_code,group_id
Kind regards
OlegEdited by: oleg2 09/22/2009 06:30 - Add Group by at the end
Maybe you are looking for
-
All the Apps keep crashing when printing, after I move from El Capitan in Sierra
Dear support team,After that I upgraded from El Capitan in Sierra, I can't print from an application such as Adobe CC (all versions), Microsoft Office (2011). All applications are keep crashing when I do the print command. I tried to reset the prefer
-
What Japanese language pack is compatible with Thunderbird 24.0
I need to be able to change the Japanese locale. The xpi is available online are not compatible with our thunderbird. What version of Japanese language is compatible? Where can I get?
-
How can I get the sound card to play on the speakers of the car?
How can I get the sound card to play on the speakers of the car?
-
@font-face-range unicode is supported in the latest version?
CSS3 definesa descriptor for unicode - range in the rule @font-face. Is this supported in Firefox 8, or is it planned?
-
Qosmio F10; White screen at startup
About a week ago my laptop starts with the screen does not. Strange! Everything seems to work fine, power lights on the hard drive whirring away etc but nothing Visual. After having read the manual I touch FN key and f5 and the screen appeared. Now t