I have two tables A & B
A have details of unique employee with location, ecode & name.
B has Leads with Lead_id, Location & Lead_Number.
So now I want details in third table based on following condition.
Allocation of Table B Leads (all fields) in round robin fashion as per details given in Table A of Employee. Basic distribution will be based on Location matching. So if on particular location there is
4 Unique employee are available then they will have allocation of leads in round robin fashion of its
respected location. Number of available unique employees will be as per Table A.
There is condition of lead allocation per location will be restricted to allocation of maximum 10 or 20 leads per employee of respective location or for all location.
Final output availability in third table C with sorting order by location & ecode wise.
Please help to get me this, have tried so many options but not got exact requirement.