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!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

Logic for Best Matching from possible row...

user481231Dec 14 2010 — edited Dec 17 2010
Hi All,

For example I have below columns and values in my test table

create table test(level1 number,level2 number,level3 number,level4 number,level5 number,level6 number,level7 number,level8 number)

insert into test values(2,3,4,5,6,7,8,9)
insert into test values(12,13,14,15,16,17,18,19)
insert into test values(5,6,7,8,9,11,13,15)
insert into test values(7,8,9,10,11,12,13,14)
insert into test values(9,10,13 ,14,15,16,17,18)
insert into test values(11,22,27,28,29,30,31,32)

select * from test;

2 3 4 5 6 7 8 9 output should be 9
12 13 14 15 16 17 18 19 output should be 12
5 6 7 8 9 11 13 15 output should be 13
7 8 9 10 11 12 13 14 output should be 12
9 10 13 14 15 16 17 18 output should be 13
11 22 27 28 29 30 31 32 output should be 22

when I input a number Ex:12 for each row If there is any column matching exactly it should be dispalyed
IF NOT the most possible highest matching number for that row should be displayed.

is there any in built functions can we use for this ? If anyboyd having this type of logic
please send to me. I think its similar to vlookup in Excel.

Thanks in advance.
Devender
This post has been answered by MichaelS on Dec 15 2010
Jump to Answer

Comments

Processing
Locked Post
New comments cannot be posted to this locked post.

Post Details

Locked on Jan 14 2011
Added on Dec 14 2010
10 comments
653 views