Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Comparing the record with one another

SmileMay 4 2012 — edited May 4 2012
Hi ,
I've the following requirement
I dont have idea that can be done with sql Or need to implement in procedure
CREATE TABLE TEST_TEST1
( 
  OB_ID  NUMBER(18),
  R_CD  VARCHAR2(20 BYTE),
  RNG     VARCHAR2(21 BYTE)
)

Insert into TEST_TEST1   (OB_ID, R_CD, RNG) Values   (9776, 'LCO', 'A+');
Insert into TEST_TEST1   (OB_ID, R_CD, RNG) Values   (19173, 'ISO', 'A++');
Insert into TEST_TEST1   (OB_ID, R_CD, RNG) Values   (16543, 'ISO', 'B-');
Insert into TEST_TEST1   (OB_ID, R_CD, RNG) Values   (13113, 'SRG', 'B+');
Insert into TEST_TEST1   (OB_ID, R_CD, RNG) Values   (13113, 'ISO', 'B++');
Insert into TEST_TEST1   (OB_ID, R_CD, RNG) Values   (14733, 'ISO', 'BB');
Insert into TEST_TEST1   (OB_ID, R_CD, RNG) Values   (28951, 'LCO', 'AA');
Insert into TEST_TEST1   (OB_ID, R_CD, RNG) Values   (20702, 'LCO', 'A+');
Insert into TEST_TEST1   (OB_ID, R_CD, RNG) Values   (30856, 'ISO', 'A-');
Insert into TEST_TEST1   (OB_ID, R_CD, RNG) Values   (19173, 'OGR', 'A++');
Insert into TEST_TEST1   (OB_ID, R_CD, RNG) Values   (16543, 'OGR', 'B-');
Insert into TEST_TEST1   (OB_ID, R_CD, RNG) Values   (16543, 'OGR', 'B+');
Insert into TEST_TEST1   (OB_ID, R_CD, RNG) Values   (13113, 'OGR', 'B-');
Insert into TEST_TEST1   (OB_ID, R_CD, RNG) Values   (14733, 'OGR', 'BB');
Insert into TEST_TEST1   (OB_ID, R_CD, RNG) Values   (30856, 'OGR', 'A-');
Insert into TEST_TEST1   (OB_ID, R_CD, RNG) Values   (30856, 'OGR', 'AA');
Need to find out the maximum RNG with one another
For ex: 9776 with 19173 and check the maximum of these 2 rng ( A+ with A++ and higest is A++ )
9776 with 19173
....
...
9776 with 30856 ( In this 30856 are having 2 records so maximum of these 2 should be calculated and then compare with 9776 )
19173 with 16543 till 19173 with 30856
Like wise i need to check each record with the another record in the table


Sample output should be
OB_ID1 OB_ID2 FIN_RAT
9776 19173 A++
9776 16543 B-
9776 13113 B++ (there are 3 records for 13113 so higest of these 3 is B++
.....
Till
30856 14733 BB

Could you hint me how can i proceed further to complete this requirement

Thank you

Edited by: Smile on May 4, 2012 5:05 AM
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jun 1 2012
Added on May 4 2012
3 comments
75 views