View Full Version : Selecting equal amount of records


sooslik
07-12-2007, 05:00 AM
I was wondering if someone could help me.
I have a simple table with data that gets updated daily. I need to split the data into 5 equal parts for work distribution. Because the amount of records always changes I can not go by numbering so I need to go by percentage, to split it into 5 ( 20% ) parts. Please help.

chergh
07-12-2007, 06:42 AM
I assume once the work is assigned you have a way of identifying that it is assigned in which case you should be able to use:

SELECT TOP 20 PERCENT *
FROM tbl_name
WHERE work = unassigned
ORDER BY whatever

Then you will need to use

SELECT TOP 25 PERCENT

Then

SELECT TOP 33 PERCENT

then

SELECT TOP 50%

Then

SELECT *

sooslik
07-12-2007, 06:52 AM
Actually I did not make a way to identify the assigned work because all of the work should be assigned each day. Can I do without that option, or if not how do I identify those records?

chergh
07-12-2007, 06:54 AM
So how do you avoid having work that was done the previous day being assigned again the next day? and how do people know which records are assigned to them?

sooslik
07-12-2007, 07:04 AM
They throw any leftover work at the end of each day, so they do not hit up against each other the next day, but technically everything should be completed by the end of the day. As far as what work, all 5 people get random 20% each, I needed it so it breakes the 20% into 5 queries so I can assign a button for each person on a form. This way every morning they click their name and new, updated 20% is there.

neileg
07-12-2007, 08:11 AM
You could cycle through the data in VBA assigning a number 1 to 5 to each record and query this out. I can't help you witth the code, though. I only do simple things ;)