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!

Need Help on designing a PL/SQl query?

877170Jul 22 2011 — edited Jul 25 2011
Hi all

i have query which scores a customer details on some factors and gives it a rank

I have a table called agents which holds the agents details.

This is how i get the rank:
select *
from (
select customer_name ,agent_number
customer_number,
customer_score,
agent_score,
customer_score+agent_score total_score,
Rank() over(PARTITION BY Name ORDER BY (customer_score+agent_score) DESC) as Ranker
from customer,agents )
where ranker = 1

The agents table has agent_number and agent_Name....

By the above query i check various score against all available agents and assign customers to agents who have highest score or rank is 1

But my problem is who to loop through the process.. i mean after the intial customers are assinged with agents

it should run again for remaining customers and for agents who are free(and rank for them is 1) should be checked for assignment

Once all agents are assigned but still more customers are available then agents even thoug they are already assigned they can be assigned now since no agent is free...

Hope my quetsion is clear..sorry for my english..newbie to PL/SQl
This post has been answered by Solomon Yakobson on Jul 25 2011
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Aug 22 2011
Added on Jul 22 2011
39 comments
341 views