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)
 assign to a user based on row_number

Author  Topic 

yosiasz
Master Smack Fu Yak Hacker

1635 Posts

Posted - 2011-07-21 : 19:33:53
Greetings

Given a certain task assignment table how could I go about bulk assigning tasks to all users evenly? I tried cross apply to users with row_number() over ... but that exploded the result set. So what I would like to do is see how many rows there are, divide by number of users and then assign task based on row number ranges?

How would I go about doing something like that? Let me gather some sample data as you chew on that

Gracias

If you don't have the passion to help people, you have no passion

Vinnie881
Master Smack Fu Yak Hacker

1231 Posts

Posted - 2011-07-21 : 22:28:07
BAHAHA, I needed to edit and delete what I posted, I apparently didn't read what you requested at all!

If you want, post some sample data and I'll try to give you an example if you are still having issues.
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2011-07-21 : 22:35:37
check out ntile(). Think this is what you wanted


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

yosiasz
Master Smack Fu Yak Hacker

1635 Posts

Posted - 2011-07-22 : 10:52:43
YES !!! NTILE is a beauty got it working!

Thanks very much!

If you don't have the passion to help people, you have no passion
Go to Top of Page
   

- Advertisement -