Click here to Skip to main content
15,891,864 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi I Want to Divide certain Customer(Ex 100) among 2 Employees having Count(10) set in Table.
so i want the result as
10 CUstomer should be assiged to 1 Employee
and other 10 Customer should be assign to 2 Employee

and rest of the 80 Customer should be assinged equally of (20) each day

next day 20
next day 20
....

thanks
Posted
Comments
Deepu S Nair 27-Apr-15 3:28am    
So what you tried so far?
deepankarbhatnagar 27-Apr-15 3:47am    
Your code please
Tomas Takac 27-Apr-15 4:03am    
This sounds more like an exercise. In real-life application you would rather assign the customers on the fly on a FIFO basis. Assigning customers to employees for days in advance is not very flexible.
Sachin MCA2012 27-Apr-15 4:46am    
select ClientCode,1 as ProductID from @ProcessTable where BranchCode=@BranchCode
)Process1Close
left outer join
( select * from
(
select ROW_NUMBER() over(order by AlreadyAssignedCount) as RN,HRMSEMP.HRMSEmpCode as EMPCode,HRMSEMP. AlreadyAssignedCount 'AlreadyAssignedCount' from
( select EMP.*,isnull(EachEmpCount.TotalCnt,0) as AlreadyAssignedCount from @HRMSEMP EMP
left outer join
(select EmpID,count (ClientID)TotalCnt from CRMN_Project_Assign where ProductId =1 and ProjectID=@ProcessID
group by EmpID
)EachEmpCount on EMP.HRMSEmpCode = EachEmpCount.EmpID
)HRMSEMP
)EMP --where RN=@b
)EMP1 on
EMP1.RN =
(main.RN - 1) %
(
select count(RN) from @HRMSEMP
) + 1 where EMP1.EMPCode is not null
order by main.RN
Tomas Takac 27-Apr-15 5:25am    
Comments are not the right place to post code. Use "Improve question" button to edit your question and put the code there. Don't forget to properly format it so people can easily read it. Then delete these comments to keep the discussion clean. Cheers.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900