l have the following table and data and expected output with my rules
drop table test_new
create table test_new (id number(9), loc1 number(9), loc2 number(9), percentage number(9));
insert into test_new values (1,1,2,0);
insert into test_new values(2,1,3,10);
insert into test_new values(3,1,4,5);
insert into test_new values(4,1,5,45);
insert into test_new values(5,2,3,0);
insert into test_new values(6,2,4,90);
insert into test_new values(7,2,5,0);
insert into test_new values(8,3,4,0);
insert into test_new values(9,3,5,0);
insert into test_new values(10,4,5,40);
insert into test_new values(11,7,5,0);
insert into test_new values(12,9,4,0);
insert into test_new values(13,10,5,90);
insert into test_new values(14,11,5,70);
insert into test_new values(15,1,15,45);
in need this form The query show that
id loc1 loc2 percentage
15 1 15 45
2 1 3 10
6 2 4 90
13 10 5 90
Not this one
id loc1 loc2 percentage
2 1 3 10
15 1 15 45
6 2 4 90
13 10 5 90
Rules:
- show
id, loc1, loc2, percentagewhere percentage greater than zero. - remove any redundance of data in column
loc2so the remove row that has lower value of percentage. - sort data based on
percentage ascand group it based column loc1.
Give this a try.
However, I think that based on your comments (not on your result table, which seems to be wrong), this is what you’re expecting: