Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 Help to get my desired output

Author  Topic 

tsaliki
Starting Member

19 Posts

Posted - 2013-09-19 : 06:11:45

i have a table emp with columns empname and highprority jobs.


for example i have 3 emp and 10 high priority jobs(assume that high priority jobs are from h1- h10).I want to make sure to assign highpriority jobs in such a way that each employee must assign same no of jobs,( for example ,tsaliki has here 2 high priority jobs,sasi 2 and srinivas 1 .SO while inserting the next high priority job first it should assign the high priorty job h6 to srinivas since he has low high priorrity jobs compared to others.likewise everytime while assigning the jobs to each employee i want to make sure that all employess must have same no of high priority jobs or just 1 more .Becasue here there are 10 high priority jobs.So ultimately my goal is to assign 3 high priority jobs to each emp and the other can be assigned to any emp since all other 3 has same high proroty jobs.



The records are as follows-


empname highpriorityjobs

tsaliki h1,h2
sasi h3,h4
srinivas h5

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2013-09-22 : 12:58:33
Are you storing highpriorityjobs values as csv? Also do you want to see the count of number of jobs and decide if the employee has high priority job or not?

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2013-09-22 : 13:11:41
Storing high priority jobs as a list is a bad idea. You should be using a bridge table to represent this relationship.

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs
Go to Top of Page
   

- Advertisement -