Example: There has 3 areas : A, B ,C , and each area has some persons.
create table Person (name varchar2(2), area varchar2(2));
insert into Person values('A1','A'); --row 1
insert into Person values('A2','A'); --row 2
insert into Person values('A3','A'); --row 3
insert into Person values('A4','A'); --row 4
insert into Person values('B1','B'); --row 5
insert into Person values('C1','C'); --row 6
insert into Person values('C2','C'); --row 7
result as following:
A B C
--------------
A1 B1 C1
A2 C2
A3
A4
If we "select * from Person", then we got all rows.
Now want to choose volunteers from every area, the rule is to choose a person from each area orderly, until N persons are chose. If N = 6, the sequence is
A1, B1, C1, A2, C2, A3
and want to return rows 1,5,6,2,7,3 (the rows' order is not important) from Person.
How to create a procedure to do this? And I wish the returned rows just like returned from a select sentence. (can be easily filled into a DataTable and then be used in a program.)
Thank you!!