Ignore duplicate rows - need help
i am having thousands of records in a table as below
polno polinsured polid polinsrdname polrenewalno polcommdate polexpdate polrendate polsi polpremium
POL00001 INSRD0001 id00001 ABCD 0 01-01-2000 31-12-2000 01-01-2001 1000.00 10
POL00001 INSRD0001 id00002 ABCD 0 01-01-2000 31-12-2000 01-01-2001 1000.00 10
POL00001 INSRD0001 id00003 ABCD 0 01-01-2000 31-12-2000 01-01-2001 1000.00 10
POL00001 INSRD0001 id00004 ABCD 0 01-01-2000 31-12-2000 01-01-2001 1000.00 10
POL00002 INSRD0101 id00001 WXYZ 0 01-01-2000 31-12-2000 01-01-2001 1000.00 10
POL00002 INSRD0101 id00002 WXYZ 0 01-01-2000 31-12-2000 01-01-2001 1000.00 10
POL00002 INSRD0101 id00003 WXYZ 0 01-01-2000 31-12-2000 01-01-2001 1000.00 10
POL00002 INSRD0101 id00004 WXYZ 0 01-01-2000 31-12-2000 01-01-2001 1000.00 10
now i want to list only those records where records is having max as polid for each policy
POL00001 INSRD0001 id00001 ABCD 0 01-01-2000
31-12-2000 01-01-2001 1000.00 10
POL00001 INSRD0001 id00002 ABCD 0 01-01-2000
31-12-2000 01-01-2001 1000.00 10
POL00001 INSRD0001 id00003 ABCD 0 01-01-2000
31-12-2000 01-01-2001 1000.00 10POL00001 INSRD0001 id00004 ABCD 0 01-01-2000
31-12-2000 01-01-2001 1000.00 10
POL00002 INSRD0101 id00001 WXYZ 0 01-01-2000
31-12-2000 01-01-2001 1000.00 10
POL00002 INSRD0101 id00002 WXYZ 0 01-01-2000
31-12-2000 01-01-2001 1000.00 10
POL00002 INSRD0101 id00003 WXYZ 0 01-01-2000
31-12-2000 01-01-2001 1000.00 10POL00002 INSRD0101 id00004 WXYZ 0 01-01-2000
31-12-2000 01-01-2001 1000.00 10
>
Can you say these two records are identical?
I don't think so. Just look at the highlighted once.
Regards
Satyaki De.
Similar Messages
-
SQL Query : sum only numbers in row - need help
Pls see data below. I would like to display only 8 rows and BRH CCN rows should be merged together and displayed as - BRH 98 2 instead of 2 rows. The rest of the rows should remain as is. Please help.
CCN SERVICES MANUFACTURING
ASL 138 NA
BRH 98 NA
BRH NA 2
C10000 NA 0
C40000 NA 0
DAO NA 10
E10000 NA 0
I10000 NA 0
M10000 NA 0
Edited by: auxilia on Nov 7, 2009 6:25 AMwith t as (
select 'ASL' ccn,'138' services,'NA' manufacturing from dual union all
select 'BRH','98','NA' from dual union all
select 'BRH','NA','2' from dual union all
select 'C10000','NA','0' from dual union all
select 'C40000','NA','0' from dual union all
select 'DAO','NA','10' from dual union all
select 'E10000','NA','0' from dual union all
select 'I10000','NA','0' from dual union all
select 'M10000','NA','0' from dual
select ccn,
nvl(max(case services when 'NA' then null else services end),'NA') services,
nvl(max(case manufacturing when 'NA' then null else manufacturing end),'NA') manufacturing
from t
group by ccn
CCN SERVICES MANUFACTURING
E10000 NA 0
C10000 NA 0
BRH 98 2
M10000 NA 0
C40000 NA 0
ASL 138 NA
I10000 NA 0
DAO NA 10
8 rows selected.
SQL> SY.
Edited by: Solomon Yakobson on Nov 7, 2009 6:46 AM -
Duplicate partitions, need help to understand and fix.
So I was looking for a USB that I plugged in and went into /media/usbhd-sdb4/miles and realized all its contents was from my home directory.
So I created a random file in my home directory to see if it would also update /media/usbhd-sdb4/miles , and it did.
Can someone help me understand what is happening?
Also if I can fuse sdb4 and sdb2 as one, and partition it as my home directory without losing its contents?
Below is some information that I think would be helpful.
Thank you.
[miles]> cd /media/usbhd-sdb4/
[usbhd-sdb4]> ls -l
total 20
drwx------ 2 root root 16384 May 28 14:16 lost+found
drwx------ 76 miles users 4096 Oct 15 00:42 miles
[usbhd-sdb4]> cd miles
[miles]> pwd
/media/usbhd-sdb4/miles
[miles]>
lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 465.8G 0 disk
├─sda1 8:1 0 19.5G 0 part
└─sda2 8:2 0 446.2G 0 part
sdb 8:16 0 465.8G 0 disk
├─sdb1 8:17 0 102M 0 part /media/usbhd-sdb1
├─sdb2 8:18 0 258.9M 0 part [SWAP]
├─sdb3 8:19 0 14.7G 0 part /
└─sdb4 8:20 0 450.8G 0 part /media/usbhd-sdb4
sr0 11:0 1 1024M 0 romCheck your udev rules...
-
Need help inserting recursively
I am writing a binary search tree, the tree nodes are basically string objects encapsulated by the TreeNode class. I have trouble writng the insert(Comparable item) which insert item to my BST. I have:
public void insert ( Comparable item ) throws BST_Exception{
if(root == null)
root = new TreeNode(item);
else
try{
insertItem(root, item);
}catch(BST_Exception e){
//Ignore
duplicates
}And a helper method:
private TreeNode insertItem (TreeNode t, Comparable item)
throws BST_Exception{
System.out.println("t = " + t + " item = " + item);
//System.out.println("result = " + result);
if(t == null){
t = new TreeNode(item);
System.out.println("New Node: " + t);
}else if(t.compareTo(new TreeNode(item)) < 0){
t.setLeft(insertItem(t.getLeft(), item));
}else if(t.compareTo(new TreeNode(item)) > 0){
t.setRight(insertItem(t.getRight(), item));
}else{
throw new BST_Exception("Duplicate nodes! " + item);
return t;
}in this case item is of type String and TreeNode implements the Comparable interface just compare two string values.
I wrote a driver program executing the insertion methods above. But it didn't work out the way i want it to be:
t = 16 item = 13
t = null item = 13
New Node: 13
t = 16 item = 2
t = null item = 2
New Node: 2
t = 16 item = 11
t = 13 item = 11
t = null item = 11 //t should be 2
New Node: 11
t = 16 item = 15
t = 13 item = 15
t = null item = 15 //
New Node: 15
t = 16 item = 6
t = 2 item = 6
t = null item = 6 //
New Node: 6
t = 16 item = 10
t = 13 item = 10
t = 11 item = 10
t = null item = 10 //
New Node: 10
t = 16 item = 16
My input file is:
16
13
2
11
15
6
10
16
Any idea what i am doing wrong in insertItem()? Thanks!Hello,
Try the following code and you will see that the result will be -1, which means that in Java 16 is "less" than 2.
public class TestString
public static void main(String[] args)
System.out.println("16".compareTo("2"));
}You need to compare your Strings as integers whenever you have integers.
Hope this helps -
Need help using dbms_scheduler to submit an immediate job on the database
Hi. I need help using dbms_scheduler to submit an immediate job on the database. Essentially I want to issue a one-time call to an Oracle Stored Procedure - this procedure will then send an email. I've never used dbms_scheduler before, but here's what I have so far.
So my Program is a stored database procedure named 'TTMS.dropperVacationConflict_Notify', but my problem is that I need to pass 3 parameter values to this job each time I run it. This is what I can't figure out. The procedure expects an 'Id' as number(5), begin_dt as a date, and end_dt as a date.
How do I pass these values when I run my job? Can anyone help?
begin
dbms_scheduler.create_program(program_name=> 'PROG_DROPVACCONFLICTS_NOTIFY',
program_type=> 'STORED_PROCEDURE',
program_action=> 'TTMS.dropperVacationConflict_Notify',
number_of_arguments => 3,
enabled=>true,
comments=> 'Procedure to notify PCM of a Dropper Vacation Conflict. Pass in Dropper Id, Begin_dt, and End_dt');
end;
begin
dbms_scheduler.create_schedule
(schedule_name=> 'INTERVAL_EVERY5_MINUTES',
start_date=> trunc(sysdate)+18/24,
repeat_interval => 'freq=MINUTELY;interval=5',
end_date => null
comments=> 'Runtime: Every day all 5 minutes, forever'
end;
begin
dbms_scheduler.create_job
(job_name => 'JOB_DROPVACCONFLICTS_NOTIFY',
program_name => 'PROG_DROPVACCONFLICTS_NOTIFY',
schedule_name => 'INTERVAL_EVERY5_MINUTES',
enabled => true,
auto_drop => true,
comments => 'Job to notify PCM of Dropper Vacation Conflicts'
end;
/And I use this to execute the job as needed...
begin
dbms_scheduler.run_job('JOB_DROPVACCONFLICTS_NOTIFY',true);
end;
/Duplicate Post
Need help using dbms_scheduler to submit an immediate job on the database -
Need help on How to delete duplicate data
Hi All
I need your help in finding the best way to delete duplicate data from a table.
Table is like
create table table1 (col1 varchar2(10), col2 varchar2(20), col3 varchar2(30));
Insert into table1 ('ABC', 'DEF','FGH');
Insert into table1 ('ABC', 'DEF','FGH');
Insert into table1 ('ABC', 'DEF','FGH');
Insert into table1 ('ABC', 'DEF','FGH');
Now I want a sql statement which will delete the duplicate rows and leaves 1 row of that data in the table. ie.in the above example delete 3 rows of duplicate data and leave a row of that data in the table. My oracle version is 8i.
Appreciate your help in advance.Either of these will work, the best approach will depend on how big the table is, and how many duplicates there are.
SQL> SELECT * FROM table1;
COL1 COL2 COL3
ABC DEF FGH
ABC DEF FGH
ABC DEF FGH
ABC DEF FGH
ABC DEF IJK
BCD EFG HIJ
BCD EFG HIJ
SQL> DELETE FROM table1 o
2 WHERE rowid <> (SELECT MAX(rowid)
3 FROM table1 i
4 WHERE o.col1 = i.col1 and
5 o.col2 = i.col2 and
6 o.col3 = i.col3);
4 rows deleted.
SQL> SELECT * FROM table1;
COL1 COL2 COL3
ABC DEF FGH
ABC DEF IJK
BCD EFG HIJ
SQL> ROLLBACK;
Rollback complete.
SQL> CREATE TABLE table1_tmp AS
2 SELECT DISTINCT * FROM table1;
Table created.
SQL> TRUNCATE TABLE table1;
Table truncated.
SQL> INSERT INTO table1
2 SELECT * FROM table1_tmp;
3 rows created.
SQL> SELECT * FROM table1;
COL1 COL2 COL3
ABC DEF FGH
ABC DEF IJK
BCD EFG HIJThere are other approaches as well (e.g. see the EXCEPTIONS INTO clause of the ALTER TABLE command), but these are the most straightforward.
HTH
John -
I have two tables MEMBER_ADRESS and MEMBER_ORDER. The MEMBER_ADRESS has duplicate rows in it based on MEMBER_ID and MATCH_VALUE. These duplicate ADDRESS_IDs were used in MEMBER_ORDER. I need to remove the duplicates from MEMBER_ADRESS making sure I keep the one with PRIMARY_FLAG = ‘Y’ and update MEMBER_ORDER.ADDRESS_ID to the MEMBER_ADRESS.ADDRESS_ID that I kept.
I am on 11gR1
Thanks for the help.
CREATE TABLE MEMBER_ADRESS
ADDRESS_ID NUMBER,
MEMBER_ID NUMBER,
ADDRESS_1 VARCHAR2(30 BYTE),
ADDRESS_2 VARCHAR2(30 BYTE),
CITY VARCHAR2(25 BYTE),
STATE VARCHAR2(2 BYTE),
ZIPCODE VARCHAR2(10 BYTE),
CREATION_DATE DATE,
LAST_UPDATE_DATE DATE,
PRIMARY_FLAG CHAR(1 BYTE),
ADDITIONAL_COMPANY_INFO VARCHAR2(40 BYTE),
MATCH_VALUE NUMBER(38) GENERATED ALWAYS AS (TO_NUMBER( REGEXP_REPLACE ("ADDITIONAL_COMPANY_INFO"||"ADDRESS_1"||"ADDRESS_2"||"CITY"||"STATE"||"ZIPCODE",'[^[:digit:]]')))
Insert into MEMBER_ADRESS
(ADDRESS_ID, MEMBER_ID, ADDRESS_1, ZIPCODE, CREATION_DATE, LAST_UPDATE_DATE, PRIMARY_FLAG, MATCH_VALUE)
Values
(200, 30, '11 Hourse Rd.',
'58754', TO_DATE('08/11/2011 10:56:25', 'MM/DD/YYYY HH24:MI:SS'), TO_DATE('08/12/2011 10:34:10', 'MM/DD/YYYY HH24:MI:SS'), 'Y', 1158754);
Insert into MEMBER_ADRESS
(ADDRESS_ID, MEMBER_ID, ADDRESS_1, ZIPCODE, CREATION_DATE, LAST_UPDATE_DATE, PRIMARY_FLAG, MATCH_VALUE)
Values
(230, 12, '101 Banks St',
'58487', TO_DATE('08/11/2011 10:56:25', 'MM/DD/YYYY HH24:MI:SS'), TO_DATE('08/12/2011 10:35:42', 'MM/DD/YYYY HH24:MI:SS'), 'N', 10158487);
Insert into MEMBER_ADRESS
(ADDRESS_ID, MEMBER_ID, ADDRESS_1, ZIPCODE, CREATION_DATE, LAST_UPDATE_DATE, PRIMARY_FLAG, MATCH_VALUE)
Values
(232, 12, '101 Banks Street',
'58487', TO_DATE('08/11/2011 10:56:25', 'MM/DD/YYYY HH24:MI:SS'), TO_DATE('08/12/2011 10:41:15', 'MM/DD/YYYY HH24:MI:SS'), 'N', 10158487);
Insert into MEMBER_ADRESS
(ADDRESS_ID, MEMBER_ID, ADDRESS_1, ZIPCODE, CREATION_DATE, LAST_UPDATE_DATE, PRIMARY_FLAG, MATCH_VALUE)
Values
(228, 12, '101 Banks St.',
'58487', TO_DATE('08/11/2011 10:56:25', 'MM/DD/YYYY HH24:MI:SS'), TO_DATE('08/12/2011 10:38:19', 'MM/DD/YYYY HH24:MI:SS'), 'N', 10158487);
Insert into MEMBER_ADRESS
(ADDRESS_ID, MEMBER_ID, ADDRESS_1, ZIPCODE, CREATION_DATE, LAST_UPDATE_DATE, PRIMARY_FLAG, MATCH_VALUE)
Values
(221, 25, '881 Green Road',
'58887', TO_DATE('08/11/2011 10:56:25', 'MM/DD/YYYY HH24:MI:SS'), TO_DATE('08/12/2011 10:34:18', 'MM/DD/YYYY HH24:MI:SS'), 'Y', 88158887);
Insert into MEMBER_ADRESS
(ADDRESS_ID, MEMBER_ID, ADDRESS_1, ZIPCODE, CREATION_DATE, LAST_UPDATE_DATE, PRIMARY_FLAG, MATCH_VALUE)
Values
(278, 28, '2811 Brown St.',
'58224', TO_DATE('08/11/2011 10:56:25', 'MM/DD/YYYY HH24:MI:SS'), TO_DATE('08/12/2011 10:36:11', 'MM/DD/YYYY HH24:MI:SS'), 'N', 281158224);
Insert into MEMBER_ADRESS
(ADDRESS_ID, MEMBER_ID, ADDRESS_1, ZIPCODE, CREATION_DATE, LAST_UPDATE_DATE, PRIMARY_FLAG, MATCH_VALUE)
Values
(280, 28, '2811 Brown Street',
'58224', TO_DATE('08/11/2011 10:56:25', 'MM/DD/YYYY HH24:MI:SS'), TO_DATE('08/12/2011 10:45:00', 'MM/DD/YYYY HH24:MI:SS'), 'Y', 281158224);
Insert into MEMBER_ADRESS
(ADDRESS_ID, MEMBER_ID, ADDRESS_1, ADDRESS_2, ZIPCODE, CREATION_DATE, LAST_UPDATE_DATE, PRIMARY_FLAG, MATCH_VALUE)
Values
(300, 12, '3421 West North Street', 'x',
'58488', TO_DATE('08/11/2011 10:56:25', 'MM/DD/YYYY HH24:MI:SS'), TO_DATE('08/12/2011 10:42:04', 'MM/DD/YYYY HH24:MI:SS'), 'Y', 342158488);
COMMIT;
CREATE TABLE MEMBER_ORDER
ORDER_ID NUMBER,
ADDRESS_ID NUMBER,
MEMBER_ID NUMBER
Insert into MEMBER_ORDER
(ORDER_ID, ADDRESS_ID, MEMBER_ID)
Values
(3, 200, 30);
Insert into MEMBER_ORDER
(ORDER_ID, ADDRESS_ID, MEMBER_ID)
Values
(4, 230, 12);
Insert into MEMBER_ORDER
(ORDER_ID, ADDRESS_ID, MEMBER_ID)
Values
(5, 228, 12);
Insert into MEMBER_ORDER
(ORDER_ID, ADDRESS_ID, MEMBER_ID)
Values
(6, 278, 28);
Insert into MEMBER_ORDER
(ORDER_ID, ADDRESS_ID, MEMBER_ID)
Values
(8, 278, 28);
Insert into MEMBER_ORDER
(ORDER_ID, ADDRESS_ID, MEMBER_ID)
Values
(10, 230, 12);
COMMIT;Hi John;
Sorry I missed your post. Yes sorry about the flag. Please take a look as these before and after sets. I hope this helps. I should have posted this in the begining.
MEMBER_ORDER (BEFORE)
ORDER_ID ADDRESS_ID MEMEBER_ID
4 228 12
10 230 12
5 230 12
11 232 12
12 300 12
8 278 28
6 278 28
3 200 30
MEMBER_ORDER (AFTER)
ORDER_ID ADDRESS_ID MEMEBER_ID
4 232 12
10 232 12
5 232 12
11 232 12
12 300 12
8 280 28
6 280 28
3 200 30
MEMBER_ADDRESS (BEFORE)
ADDRESS_ID MEMBER_ID ADDRESS_1 CREATION_DATE LAST_UPDATE_DATE PRIMARY_FLAG MATCH_VALUE
228 12 101 Banks St. 8/11/2000 10:56:25 AM 8/12/2005 10:38:19 AM N 10158487
230 12 101 Banks St 8/11/2000 10:56:25 AM 8/12/2006 10:35:42 AM N 10158487
232 12 101 Banks Street 8/11/2000 10:56:25 AM 8/12/2007 10:41:15 AM N 10158487
300 12 3421 West North Street 8/11/2000 10:56:25 AM 8/12/2011 10:42:04 AM Y 342158488
221 25 881 Green Road 8/11/2000 10:56:25 AM 8/12/2011 10:34:18 AM Y 88158887
278 28 2811 Brown St. 8/11/2000 10:56:25 AM 8/12/2006 10:36:11 AM N 281158224
280 28 2811 Brown Street 8/11/2000 10:56:25 AM 8/12/2011 10:45:00 AM Y 281158224
200 30 11 Hourse Rd. 8/11/2000 10:56:25 AM 8/12/2005 10:34:10 AM Y 1158754
MEMBER_ADDRESS (AFTER)
ADDRESS_ID MEMBER_ID ADDRESS_1 CREATION_DATE LAST_UPDATE_DATE PRIMARY_FLAG MATCH_VALUE
232 12 101 Banks Street 8/11/2000 10:56:25 AM 8/12/2007 10:41:15 AM N 10158487
300 12 3421 West North Street 8/11/2000 10:56:25 AM 8/12/2011 10:42:04 AM Y 342158488
221 25 881 Green Road 8/11/2000 10:56:25 AM 8/12/2011 10:34:18 AM Y 88158887
280 28 2811 Brown Street 8/11/2000 10:56:25 AM 8/12/2011 10:45:00 AM Y 281158224
200 30 11 Hourse Rd. 8/11/2000 10:56:25 AM 8/12/2005 10:34:10 AM Y 1158754 -
Help regarding accessing duplicate rows in a procedure
Hi All,
I have duplaicate records in my table. In my procedure, I have to access only one row and leave the remaining rows unprocessed.
For ex:-
EMPNO ENAME DEPTNO DNAME SAL
1128 SMITH 140 MARKT 200
1128 SMITH 140 MARKT 400
1128 SMITH 140 MARKT 600
1160 DARON 150 BUSSN 300
1160 DARON 150 BUSSN 500
1196 DAYLE 180 SPORT 800
In my procedure, I need to process only
1128 SMITH 140 MARKT 200
1160 DARON 150 BUSSN 300
1196 DAYLE 180 SPORT 800
only these rows and dont process the remaining rows. Instead of deleteing the duplicate rows and then accessing, how to handle this duplication in the procedure. will write a cursor and open it and process the first row. when the cursor fetches the second row, as it a duplicate interms of EMPNO, i dont want to process that and skip to 4th record. process 4th record and skip 5th as it is a duplicate and then process 6th.
Will write some validations to check whether EMPNO and DEPTNO exists in the database and and whether those two are linked to each other and then process it.
Help Appreciated how to handle it in a procedure.
ThanksHi there,
from my understanding of what you've asked, you should just need to ensure your cursor is ordered by "empno" and "sal" and then assign empno to a variable each time you fetch the cursor or loop arround depending on how you do it.
then you only process the row when the data in the cursor.empno field is different from the data in the variable.
e.g. (disclaimer: quick and dirty)
declare
v_empno number;
begin
v_empno := 0;
for v_cursor in (select * from table order by empno, sal) loop
if v_cursor.empno <> v_empno then
--process record
v_empno := v_cursor.empno;
end if;
end loop;
end; -
Need help with duplicate print jobs over network that I can't cancel
I have the Photosmart Premium All-in-One on my home network. My kids who each have laptop running Windows 7 and are connected via wireless to the printer via a DLINK DIR-655.
They hit the print button too many times and it keeps printing over and over again.
Is there a way to get the printer to stop printing these duplicates. I tried turning off/on but they just keep printing.
We're wasting paper/ink and I need help with a solution.
Please let me know. Thanks.
AngeloThere should be a button with a red 'X' on it on the front of the printer. This is the print cancel button.
Say thanks by clicking "Kudos" "thumbs up" in the post that helped you.
I am employed by HP -
Need help with disappearing header row in tables
Hey guys.
I'm working on a large document with tables (annual report). I have set up table styles with header and body cell styles. When I apply the table style to a table, then convert the first row to header row, the entire header row disappears...!
If I leave the row as body row and just apply the header cell style to it, it won't disappear. The row will only disappear if I convert it to header row in Indesign.
I checked the Word doc I imported the text from, the first row of the tables is just normal body row.
I dunno where to look so I have no idea how to fix this problem. It happens to all the tables. I was supplied this file. I don't particularly want to recreate the file. The original file was created in Creative Clouds and exported to idml for me as I have CS6.
Has anyone experienced the same problem or know what's the solution? I really need help.
Thanks in advance.It may be on the Table Options dailog box on the section of Headers and Footers> Header: Repeat Header the Skip First is check on.
-
Need help with Pivoting rows to columns
Hi,
I need help with pivoting rows to columns. I know there are other posts regarding this, but my requirement is more complex and harder. So, please give me a solution for this.
There are two tables say Table 1 and Table 2.
Table1
name address email identifier
x e g 1
f s d 2
h e n 3
k l b 4
Table2
identifier TRno zno bzid
1 T11 z11 b11
1 T12 z12 b12
1 T13 z13 b13
2 T21 z21 b21
2 T22 z22 b22
As you can see the identifier is the column that we use to map the two tables. The output should be like below
output
name address email identifier TRno1 zno1 bzid1 TRno2 zno2 bzid2 TRno3 zno3 bzid3
x e g 1 T11 z11 b11 T12 z12 b12 T13 z13 b13
f s d 2 T21 z21 b21 t22 z22 b22
Also we do not know exactly how many TRno's, zno's, etc each value in the identifier will have. There may be only 1 TRNO, zno and bzid, or there may be four.
All the values must be in separate columns, and not be just comma delimitted. There are also other conditions that i have to add to restrict the data.
So, can you please tell me what is should use to get the data in the required format? We are using Oracle 10g. Please let me know if u need any more informationSomething like this ?
SCOTT@orcl> ed
Wrote file afiedt.buf
1 select a.name,
2 a.address,
3 a.email,
4 b.* from (
5 select distinct identifier
6 ,max(trno1) trno1
7 ,max(zno1) zno1
8 ,max(bzid1) bzid1
9 ,max(trno2) trno2
10 ,max(zno2) zno2
11 ,max(bzid2) bzid2
12 ,max(trno3) trno3
13 ,max(zno3) zno3
14 ,max(bzid3) bzid3
15 ,max(trno4) trno4
16 ,max(zno4) zno4
17 ,max(bzid4) bzid4
18 from (select identifier
19 ,decode(rn,1,trno,null) trno1
20 ,decode(rn,1,zno,null) zno1
21 ,decode(rn,1,bzid,null) bzid1
22 ,decode(rn,2,trno,null) trno2
23 ,decode(rn,2,zno,null) zno2
24 ,decode(rn,2,bzid,null) bzid2
25 ,decode(rn,3,trno,null) trno3
26 ,decode(rn,3,zno,null) zno3
27 ,decode(rn,3,bzid,null) bzid3
28 ,decode(rn,4,trno,null) trno4
29 ,decode(rn,4,zno,null) zno4
30 ,decode(rn,4,bzid,null) bzid4
31 from (select identifier,
32 trno,bzid,zno,
33 dense_rank() over(partition by identifier order by trno,rownum) rn
34 from table2)
35 order by identifier)
36 group by identifier) b,table1 a
37* where a.identifier=b.identifier
SCOTT@orcl> /
NAME ADDRESS EMAIL IDENTIFIER TRNO1 ZNO1 BZID1 TRNO2 ZNO2 BZID2 TRNO3 ZNO3 BZID3 TRNO4 ZNO4 BZID4
x e g 1 T11 z11 b11 T12 z12 b12 T13 z13 b13
f s d 2 T21 z21 b21 T22 z22 b22
SCOTT@orcl> select * from table1;
NAME ADDRESS EMAIL IDENTIFIER
x e g 1
f s d 2
h e n 3
k l b 4
SCOTT@orcl> select * from table2;
IDENTIFIER TRNO ZNO BZID
1 T11 z11 b11
1 T12 z12 b12
1 T13 z13 b13
2 T21 z21 b21
2 T22 z22 b22
SCOTT@orcl>Regards
Girish Sharma -
Help with remove reversed duplicate rows?
Hi:
I have an application where I need to remove reversed duplicate rows, such as this:
select 'A' x, 'B' y from dual
union all
select 'C', 'D' from dual
union all
select 'B','A' from dual;
Output is:
X Y
A B
C D
B A
What I need is to remove the 'B A' row because it already exists in reverse form as 'A B'. It does not matter which row is kept, 'A B' or 'B A'. Just one of them needs to be removed and the other needs to stay.
Note that the actual query to generate the data is a little more involved, but I can use a with clause to make it an inline view. I'm hoping that the actual mechanics are not relevant. If that is not the case, please let me know and I'll post more details about the actual query.
Any ideas?WITH T AS
( SELECT 'HOUSE' x, 'HOUSE' y FROM DUAL UNION ALL
SELECT 'HOUSE', 'JME0609U' FROM DUAL UNION ALL
SELECT 'HOUSE', 'JME4Q08' FROM DUAL UNION ALL
SELECT 'HOUSE', 'JMEM' FROM DUAL UNION ALL
SELECT 'HOUSE', 'MATCH2' FROM DUAL UNION ALL
SELECT 'HOUSE', 'MATCH3' FROM DUAL UNION ALL
SELECT 'HOUSE', 'PGCM' FROM DUAL UNION ALL
SELECT 'HOUSE', 'PGCU' FROM DUAL UNION ALL
SELECT 'HOUSE', 'VEL' FROM DUAL UNION ALL
SELECT 'HOUSE', 'XXX08' FROM DUAL UNION ALL
SELECT 'JME0609U', 'HOUSE' FROM DUAL UNION ALL
SELECT 'JME0609U', 'JME0609U' FROM DUAL UNION ALL
SELECT 'JME0609U', 'MATCH3' FROM DUAL UNION ALL
SELECT 'JME0609U', 'PGCM' FROM DUAL UNION ALL
SELECT 'JME0609U', 'PGCU' FROM DUAL UNION ALL
SELECT 'JME0609U', 'VEL' FROM DUAL UNION ALL
SELECT 'JME0609U', 'XXX08' FROM DUAL UNION ALL
SELECT 'JMEM', 'HOUSE' FROM DUAL UNION ALL
SELECT 'JMEM', 'JMEM' FROM DUAL UNION ALL
SELECT 'JMEM', 'MATCH3' FROM DUAL UNION ALL
SELECT 'JMEM', 'PGCM' FROM DUAL UNION ALL
SELECT 'JMEM', 'PGCU' FROM DUAL UNION ALL
SELECT 'JMEM', 'VEL' FROM DUAL UNION ALL
SELECT 'JMEM', 'XXX08' FROM DUAL UNION ALL
SELECT 'MATCH2', 'HOUSE' FROM DUAL UNION ALL
SELECT 'MATCH2', 'MATCH2' FROM DUAL UNION ALL
SELECT 'MATCH2', 'MATCH3' FROM DUAL UNION ALL
SELECT 'MATCH2', 'PGCM' FROM DUAL UNION ALL
SELECT 'MATCH2', 'PGCU' FROM DUAL UNION ALL
SELECT 'MATCH2', 'VEL' FROM DUAL UNION ALL
SELECT 'MATCH2', 'XXX08' FROM DUAL UNION ALL
SELECT 'MATCH3', 'HOUSE' FROM DUAL UNION ALL
SELECT 'MATCH3', 'JME0609U' FROM DUAL UNION ALL
SELECT 'MATCH3', 'JMEM' FROM DUAL UNION ALL
SELECT 'MATCH3', 'MATCH2' FROM DUAL UNION ALL
SELECT 'MATCH3', 'MATCH3' FROM DUAL UNION ALL
SELECT 'MATCH3', 'XXX08' FROM DUAL UNION ALL
SELECT 'PGCM', 'HOUSE' FROM DUAL UNION ALL
SELECT 'PGCM', 'JME0609U' FROM DUAL UNION ALL
SELECT 'PGCM', 'JMEM' FROM DUAL UNION ALL
SELECT 'PGCM', 'MATCH2' FROM DUAL UNION ALL
SELECT 'PGCM', 'PGCM' FROM DUAL UNION ALL
SELECT 'PGCM', 'XXX08' FROM DUAL UNION ALL
SELECT 'PGCU', 'HOUSE' FROM DUAL UNION ALL
SELECT 'PGCU', 'JME0609U' FROM DUAL UNION ALL
SELECT 'PGCU', 'JMEM' FROM DUAL UNION ALL
SELECT 'PGCU', 'MATCH2' FROM DUAL UNION ALL
SELECT 'PGCU', 'PGCU' FROM DUAL UNION ALL
SELECT 'PGCU', 'XXX08' FROM DUAL UNION ALL
SELECT 'VEL', 'HOUSE' FROM DUAL UNION ALL
SELECT 'VEL', 'JME0609U' FROM DUAL UNION ALL
SELECT 'VEL', 'JMEM' FROM DUAL UNION ALL
SELECT 'VEL', 'MATCH2' FROM DUAL UNION ALL
SELECT 'VEL', 'VEL' FROM DUAL UNION ALL
SELECT 'VEL', 'XXX08' FROM DUAL )
SELECT x, y
FROM (SELECT x, y, row_number() over (partition by least(x,y), greatest(x,y) order by rownum) rn
FROM t)
WHERE rn = 1
HOUSE,HOUSE
HOUSE,JME0609U
HOUSE,JME4Q08
HOUSE,JMEM
HOUSE,MATCH2
HOUSE,MATCH3
HOUSE,PGCM
HOUSE,PGCU
HOUSE,VEL
HOUSE,XXX08
JME0609U,JME0609U
JME0609U,MATCH3
JME0609U,PGCM
JME0609U,PGCU
JME0609U,VEL
JME0609U,XXX08
JMEM,JMEM
JMEM,MATCH3
JMEM,PGCM
JMEM,PGCU
JMEM,VEL
JMEM,XXX08
MATCH2,MATCH2
MATCH2,MATCH3
MATCH2,PGCM
MATCH2,PGCU
MATCH2,VEL
MATCH2,XXX08
MATCH3,MATCH3
MATCH3,XXX08
PGCM,PGCM
PGCM,XXX08
PGCU,PGCU
PGCU,XXX08
VEL,VEL
VEL,XXX08 -
Need help regarding updated rows
Dear sir,
need help on this query
how many rows got updated when i execute an update statementIf you are executing update statement from sqlplus session.
Make sure "feedback" is turned on. It'll show numbers of rows updated just after the command;
SQL> update tt1 set col1 = 1;
0 rows updated.
SQL> show feedback
FEEDBACK ON for 1 or more rows
SQL> set feedback off
SQL> update tt1 set col1 = 1;
SQL>Details about this sqlplus system setting:
FEED[BACK] {6|n|OFF|ON}
Display the number of records returned (when rows >= n )
OFF (or n=0) will turn the display off
ON will set n=1
Regards,
Ullhas -
Error restoring row currency - Need Help
Hi All,
Can anyone explain me how can I control the row currency???????
this is my situation:
when I navigate from page1 (with one read-only table - tableEmployees) to page2 (with a read-only table - tableSelectEmployees, with this columns: ps, eps, obs, obs2, where ps, eps and obs are the primary keys), selecting the "create" button, I need to insert a new row in tableSelectEmployees (page2) with this values (ps=2, eps=2, obs=null, obs2=null). -----> Until here everything works Fine :)
The Big problem is when I need to navigate from page2 to page3 (with a read-only table - tableAddEmployees with this columns: DOM_ID, id, meaning, where Id is the primary key). The tableAddEmployees has a Query like this:
SELECT *
FROM tableAddEmployees
WHERE NVL(tableAddEmployees.DOM_ID,0) = NVL(:1, 0)
AND tableAddEmployees.ID NOT IN (
SELECT obs
FROM tableSelectEmployees
WHERE Ps= :2
AND Eps = :3
AND NVL(obs, 0) = NVL(:4, 0))
When I select the new row created (Ps=2, Eps=2, null, null) in page 2 and go to page3 I get this error messages from the log window:
12:17:20 DEBUG (JhsActionServlet) -Request class: com.evermind.server.http.EvermindHttpServletRequest
12:17:20 DEBUG (JhsActionServlet) -Request URI: /App_S2-ViewController-context-root/S2PopUpObstaculos.do
12:17:20 DEBUG (JhsActionServlet) -Request Character Encoding: windows-1252
12:17:20 DEBUG (JhsActionServlet) -Parameter searchText:
12:17:20 DEBUG (JhsActionServlet) -Parameter event_Rollback:
12:17:20 DEBUG (JhsActionServlet) -Parameter event:
12:17:20 DEBUG (JhsActionServlet) -Parameter partial:
12:17:20 DEBUG (JhsActionServlet) -Parameter source:
12:17:20 DEBUG (JhsActionServlet) -Parameter eventValue:
12:17:20 DEBUG (JhsActionServlet) -Parameter rowKeyStr:
12:17:20 DEBUG (JhsActionServlet) -Parameter partialTargets:
12:17:20 DEBUG (JhsDataAction) -Executing action /S2PopUpObstaculos
12:17:20 DEBUG (JhsDataAction) -lastIssuedPageTimeStamp set to: 1156245440919
12:17:20 DEBUG (JhsDataAction) -Found existing searchBean for S2AltaSociais2UIModel
12:17:20 DEBUG (JhsDataAction) -Stored searchBean for S2AltaSociais2UIModel on request
12:17:20 DEBUG (JhsDataAction) -ViewObject S2DominiosLevel1: value of bind param 0 has changed: old value=0 ,new value=
12:17:20 DEBUG (JhsDataAction) -ViewObject S2DominiosLevel1: value of bind param 1 has changed: old value=0 ,new value=2
12:17:20 DEBUG (JhsDataAction) -ViewObject S2DominiosLevel1: value of bind param 2 has changed: old value=0 ,new value=2
12:17:20 DEBUG (JhsDataAction) -ViewObject S2DominiosLevel1: value of bind param 3 has changed: old value=0 ,new value=
12:17:20 DEBUG (JhsDataAction) -ViewObject S2DominiosLevel1: executing query, bind parameter values have changed
12:17:20 DEBUG (JhsDataAction) -executing onRollback
12:17:20 DEBUG (JhsDataAction) -executing Rollback ActionBinding
12:17:21 DEBUG (JhsDataAction) -Restoring row currencies
12:17:21 ERROR (JhsDataAction) -Error restoring row currency for S2ObstaculosLevel1Iterator: JBO-25020: View row of key oracle.jbo.Key[2 2 null ] not found in S2ObstaculosLevel1Iterator.
12:17:21 ERROR (JhsDataAction) -Error restoring row currency for S2ObstaculosLevel1Iterator: JBO-25020: View row of key oracle.jbo.Key[2 2 null ] not found in S2ObstaculosLevel1Iterator.
12:17:21 ERROR (JhsDataAction) -Error restoring row currency for S2ObstaculosAssoc1Iterator: JBO-25020: View row of key oracle.jbo.Key[2 2 null ] not found in S2ObstaculosAssoc1Iterator.
12:17:21 ERROR (JhsDataAction) -Error restoring row currency for S2ObstaculosLevel1Iterator: JBO-25020: View row of key oracle.jbo.Key[2 2 null ] not found in S2ObstaculosLevel1Iterator.
12:17:21 ERROR (JhsDataAction) -Error restoring row currency for S2ObstaculosLevel1Iterator: JBO-25020: View row of key oracle.jbo.Key[2 2 null ] not found in S2ObstaculosLevel1Iterator.
12:17:21 DEBUG (JhsDataAction) -ViewObject S2DominiosLevel1: value of bind param 0 has changed: old value= ,new value=278263
12:17:21 DEBUG (JhsDataAction) -ViewObject S2DominiosLevel1: value of bind param 3 has changed: old value= ,new value=278263
12:17:21 DEBUG (JhsDataAction) -ViewObject S2DominiosLevel1: executing query, bind parameter values have changed
12:17:21 DEBUG (JhsDataAction) -Storing table binding factory under key jhsTableBindings on request
12:17:21 DEBUG (JhsDataAction) -Forward set by parameter property returned: /WEB-INF/page/S2PopUpObstaculos.uix
--->If I want this null values why is JDeveloper changing the row currency?
When I select one row from page2 with values like this (2, 2, 278264, null) I get the correct response:
12:19:41 DEBUG (JhsActionServlet) -Request class: com.evermind.server.http.EvermindHttpServletRequest
12:19:41 DEBUG (JhsActionServlet) -Request URI: /App_S2-ViewController-context-root/S2PopUpObstaculos.do
12:19:41 DEBUG (JhsActionServlet) -Request Character Encoding: windows-1252
12:19:41 DEBUG (JhsActionServlet) -Parameter searchText:
12:19:41 DEBUG (JhsActionServlet) -Parameter event_Rollback:
12:19:41 DEBUG (JhsActionServlet) -Parameter event:
12:19:41 DEBUG (JhsActionServlet) -Parameter partial:
12:19:41 DEBUG (JhsActionServlet) -Parameter source:
12:19:41 DEBUG (JhsActionServlet) -Parameter eventValue:
12:19:41 DEBUG (JhsActionServlet) -Parameter rowKeyStr:
12:19:41 DEBUG (JhsActionServlet) -Parameter partialTargets:
12:19:41 DEBUG (JhsDataAction) -Executing action /S2PopUpObstaculos
12:19:41 DEBUG (JhsDataAction) -lastIssuedPageTimeStamp set to: 1156245581741
12:19:41 DEBUG (JhsDataAction) -Found existing searchBean for S2AltaSociais2UIModel
12:19:41 DEBUG (JhsDataAction) -Stored searchBean for S2AltaSociais2UIModel on request
12:19:41 DEBUG (JhsDataAction) -ViewObject S2DominiosLevel1: value of bind param 0 has changed: old value=0 ,new value=278264
12:19:41 DEBUG (JhsDataAction) -ViewObject S2DominiosLevel1: value of bind param 1 has changed: old value=0 ,new value=2
12:19:41 DEBUG (JhsDataAction) -ViewObject S2DominiosLevel1: value of bind param 2 has changed: old value=0 ,new value=2
12:19:41 DEBUG (JhsDataAction) -ViewObject S2DominiosLevel1: value of bind param 3 has changed: old value=0 ,new value=278264
12:19:41 DEBUG (JhsDataAction) -ViewObject S2DominiosLevel1: executing query, bind parameter values have changed
12:19:41 DEBUG (JhsDataAction) -executing onRollback
12:19:41 DEBUG (JhsDataAction) -executing Rollback ActionBinding
12:19:41 DEBUG (JhsDataAction) -Restoring row currencies
12:19:42 DEBUG (JhsDataAction) -ViewObject S2DominiosLevel1: bind parameter values have not changed
12:19:42 DEBUG (JhsDataAction) -Storing table binding factory under key jhsTableBindings on request
12:19:42 DEBUG (JhsDataAction) -Forward set by parameter property returned: /WEB-INF/page/S2PopUpObstaculos.uix
Can anyone help me with this problem, please?
What can I do to solve this currency problem?
Please, I really need help on this!!!
I'm using JDeveloper10.1.2, struts, uix pages.
Thanks,
AtenaCan anyone give some help here?
-
Need to remove duplicate rows from a table
Hi Gurus ,
I am using oracle 11.2.0.3 .
SQL> desc osstage.S_EVT_ACT_X;
Name Null? Type
ROW_ID NOT NULL VARCHAR2(15 CHAR)
LAST_UPD NOT NULL DATE
PAR_ROW_ID NOT NULL VARCHAR2(15 CHAR)
ATTRIB_17 NUMBER(22,7)
ATTRIB_26 DATE
ATTRIB_02 VARCHAR2(100 CHAR)
PROCESS_TIMESTAMP TIMESTAMP(6);
now when i give the below command it gives the error as someone has disabled the constraint accidently .
alter table s_evt_act_x enable constraint S_EVT_ACT_X_P1;
Error starting at line 3 in command:
alter table s_evt_act_x enable constraint S_EVT_ACT_X_P1
Error report:
SQL Error: ORA-02437: cannot validate (OSSTAGE.S_EVT_ACT_X_P1) - primary key violated
02437. 00000 - "cannot validate (%s.%s) - primary key violated"
*Cause: attempted to validate a primary key with duplicate values or null
values.
*Action: remove the duplicates and null values before enabling a primary
key.
Can you please guide me with this issue .Please refer
Script: Deleting Duplicate Rows from a Table (Doc ID 31413.1)
How to Find or Delete Duplicate Rows in a Table (Doc ID 1004425.6)
Maybe you are looking for
-
Calling script from ALV report
there is button in my report(print) when click on this it needs to display the report output in a script (which is designed for this) Please help me how to declare my itab variables in Script.... only the data and page number will change rest all tex
-
Selecting and running vi's on a compact FieldPoint 2120 via remote panel
Hi, I'm trying to provide two html files to run two different vi's on a compact fieldpoint. I can run either of them by setting them as 'run as startup' in the Build Specification which creates the startup.rtexe program on the controller but the on
-
I store my images in folders on my desktop. When I want to process photos in lightroom, I import to my laptop via network. Now I have a long line of sources and can't seem to import any more images. Now getting a message saying "unable to process
-
NonDatabase field doenot returning the value
Hi., I am using jdev11.1.5 I had created a read only view object using sql querry select count(*) "var_count",aj_appl from appl_journals where aj_status = :StatusBV and aj_appl = :appl group by aj_applI had also created a transient attrib
-
Error "Wire: is a member of a cycle
I am doing decoupling control of MIMO system in LabVIEW Control Design and Simulation module. Simulating the controller and the plant transfer functions, gives the error "Wire: is a member of a cycle".I understand this is coz of the Three transfer fu