473,651 Members | 2,994 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Assign records to Analysts

Here is my issue. I have a list of merchants (generated daily) and I
need to assign them eually to a set of analysts. Both the merchant
list and analyst list can change daily. I want to assign each merchant
with an analyst daily and need help to write out a stored procedure
for this (do not want to use VB).
Here is relevant code for the tables:
CREATE TABLE MerchList (
MerchListID int IDENTITY (1, 1) NOT NULL ,
FileDate datetime NOT NULL ,
MerchID int NOT NULL ,
AnalystID int NOT NULL ,
)

CREATE TABLE tblAnalyst (
AnalystID int IDENTITY (1, 1) NOT NULL ,
AnalystName varchar(100) NOT NULL
)

there will be about 10000 records in table MerchList and around 25
records in table tblAnalyst.

This will be used to assign work to analysts on a daily basis.

Thanks for all your help!

Vishal
Jul 20 '05 #1
5 1944

"Vishal Sinha" <vs******@yahoo .com> wrote in message
news:2f******** *************** ***@posting.goo gle.com...
Here is my issue. I have a list of merchants (generated daily) and I
need to assign them eually to a set of analysts. Both the merchant
list and analyst list can change daily. I want to assign each merchant
with an analyst daily and need help to write out a stored procedure
for this (do not want to use VB).
Here is relevant code for the tables:
CREATE TABLE MerchList (
MerchListID int IDENTITY (1, 1) NOT NULL ,
FileDate datetime NOT NULL ,
MerchID int NOT NULL ,
AnalystID int NOT NULL ,
)

CREATE TABLE tblAnalyst (
AnalystID int IDENTITY (1, 1) NOT NULL ,
AnalystName varchar(100) NOT NULL
)

there will be about 10000 records in table MerchList and around 25
records in table tblAnalyst.

This will be used to assign work to analysts on a daily basis.

Thanks for all your help!

Vishal


Your requirements aren't entirely clear (at least to me), and the tables
don't seem to have enough information (keys and constraints) to give a good
answer. Is the MerchList table repopulated every day, or are today's
merchants identified by FileDate? Can the same MerchID appear multiple times
in one day (if that is what FileDate is for)? Is the tblAnalyst table
repopulated every day? If so, then how do you track AnalystIDs over time? If
it is not, then how do you mark analysts as sick or unavailable (there seems
to be no column for that)?

Your basic requirement seems to be assigning merchants to analysts, but it
isn't clear what you mean by "equally". What happens if some analysts can
process more merchants than others, due to greater experience, better
resources or whatever? In that case, you would want to weight the
assignment, so they get more merchants assigned to them. Or what happens if
the numbers simply don't divide into each other cleanly - who gets the
'extra' merchants?

And do you have to ensure that merchants are 'rotated' among analysts, or is
it acceptable for the same merchant to be assigned to the same analyst every
day indefinitely? If you need rotation, should it be random or periodic? Are
there rules about merchants which can never be assigned to certain
analysts - a blacklist or Chinese wall?

I don't want to sound unhelpful, but I suspect you may be oversimplifying
your requirements, and if you do need to consider some of the issues I've
suggested, then it's likely that you'll end up with something too detailed
to discuss in a newsgroup.

But if it is a simple case, then I think you'll get more help by providing
some sample data, preferably for at least a couple of different days. That
should help clarify what you expect to achieve.

Simon
Jul 20 '05 #2
Thanks for the quick response,
Please see my replies below:

Re: Assign records to Analysts
From: Simon Hayes
Date Posted: 1/12/2004 1:43:00 PM
Your requirements aren't entirely clear (at least to me), and the tables
don't seem to have enough information (keys and constraints) to give a
good answer. Is the MerchList table repopulated every day, or are
today's merchants identified by FileDate? Can the same MerchID appear
multiple times in one day (if that is what FileDate is for)? Is the
tblAnalyst table repopulated every day? If so, then how do you track
AnalystIDs over time? If
it is not, then how do you mark analysts as sick or unavailable (there
seems to be no column for that)?

Vishal>> There is one record per mechant and the list is created on a
daily basis. so the table would have data for multiple dates where there
can be only one record for a merchant for any given date.

Your basic requirement seems to be assigning merchants to analysts, but
it isn't clear what you mean by "equally". What happens if some analysts
can process more merchants than others, due to greater experience,
better
resources or whatever? In that case, you would want to weight the
assignment, so they get more merchants assigned to them. Or what happens
if the numbers simply don't divide into each other cleanly - who gets
the
'extra' merchants?

Vishal>> I would need to assign equal number of merchants to analysts.
If the numbers do not divide equally then the first few get the extra
(can be order by ID - does not matter)

And do you have to ensure that merchants are 'rotated' among analysts,
or is it acceptable for the same merchant to be assigned to the same
analyst every day indefinitely? If you need rotation, should it be
random or periodic? Are
there rules about merchants which can never be assigned to certain
analysts - a blacklist or Chinese wall?

Vishal>> No rotation required

I don't want to sound unhelpful, but I suspect you may be
oversimplifying
your requirements, and if you do need to consider some of the issues
I've
suggested, then it's likely that you'll end up with something too
detailed
to discuss in a newsgroup.

But if it is a simple case, then I think you'll get more help by
providing
some sample data, preferably for at least a couple of different days.
That
should help clarify what you expect to achieve.

Simon
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 20 '05 #3
Vishal Sinha (vs******@yahoo .com) writes:
Here is my issue. I have a list of merchants (generated daily) and I
need to assign them eually to a set of analysts. Both the merchant
list and analyst list can change daily. I want to assign each merchant
with an analyst daily and need help to write out a stored procedure
for this (do not want to use VB).
Here is relevant code for the tables:
CREATE TABLE MerchList (
MerchListID int IDENTITY (1, 1) NOT NULL ,
FileDate datetime NOT NULL ,
MerchID int NOT NULL ,
AnalystID int NOT NULL ,
)

CREATE TABLE tblAnalyst (
AnalystID int IDENTITY (1, 1) NOT NULL ,
AnalystName varchar(100) NOT NULL
)

there will be about 10000 records in table MerchList and around 25
records in table tblAnalyst.


If I understood the requirements from your supplemental posting
correctly, this could be a solution:

UPDATE MerchList
SET AnalystID = MerchListID %
(SELECT COUNT(*) FROM tblAnalyst) + 1

This presumes that the AnalystIDs goes from 1 to 25 (or whatever)
without gaps. If there are gaps, or the id:s do not start at 1,
you could do:

CREATE TABLE #analystmap (id int IDENTITY(0, 1),
analystid int NOT NULL

INSERT #analystmap (analystid)
SELECT AnalystID FROM tblAnalyst ORDER BY newid()

UPDATE MerchList
SET AnalystID = a.analystid
FROM MerchList m
JOIN #analystmap a ON
m.MerchList % (SELECT COUNT(*) FROM #analystmap) = a.id

The ORDER BY newid() adds a certain randomness into the process, but
still merchants that are 25 ids apart will get the same analyst.

Disclaimer: as there was not test data included, I have not tested this.

--
Erland Sommarskog, SQL Server MVP, so****@algonet. se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinf...2000/books.asp
Jul 20 '05 #4
Your schema has no keys, no DRI and no constraints. You will also
have no data integrity. Let's fix it up:
CREATE TABLE MerchAnalysts
(file_date DATETIME NOT NULL,
REFERENCES Analysts (analyst_id),
merch_id INTEGER NOT NULL
REFERENCES Merchants (merch_id),
analyst_id INTEGER NOT NULL,
REFERENCES Analysts (analyst_id),
..
PRIMARY KEY (file_date, analyst_id, merch_id));

Since I do not know what the **real keys** for merchants and analysts
would be (SSN? Tax number, DUN number?), I have left them as
INTEGERs; fix this omission immediately! IDENTITY is never a key. I
also shortened the names to a length that will not collect garbage
strings or be so long they cannot display easily, etc.

CREATE TABLE Analysts
(analyst_id INTEGER NOT NULL PRIMARY KEY,
analyst_name VARCHAR(35) NOT NULL,
..);

CREATE TABLE Merchants
(merch_id INTEGER NOT NULL PRIMARY KEY,
analyst_name VARCHAR(35) NOT NULL,
..);
I want to assign each merchant with an analyst daily and need help

to write out a stored procedure for this <<

What is the rule for the assignments? To write a procedure, we need
to have a spec. Do you want to divide them up evenly each day? Are
certain analysts assigned to certain merchants, but have an
alternative analyst if the primary one is not at work? Are the rules
more complex than that either of those possibilities?
Jul 20 '05 #5
Thanks for the Suggestions - it is EXACTLY what I needed. I did post a
rather simplified version of table design for illustration purposes.

Thanks everyone!

Vishal
Erland Sommarskog <so****@algonet .se> wrote in message news:<Xn******* *************** @127.0.0.1>...
Vishal Sinha (vs******@yahoo .com) writes:
Here is my issue. I have a list of merchants (generated daily) and I
need to assign them eually to a set of analysts. Both the merchant
list and analyst list can change daily. I want to assign each merchant
with an analyst daily and need help to write out a stored procedure
for this (do not want to use VB).
Here is relevant code for the tables:
CREATE TABLE MerchList (
MerchListID int IDENTITY (1, 1) NOT NULL ,
FileDate datetime NOT NULL ,
MerchID int NOT NULL ,
AnalystID int NOT NULL ,
)

CREATE TABLE tblAnalyst (
AnalystID int IDENTITY (1, 1) NOT NULL ,
AnalystName varchar(100) NOT NULL
)

there will be about 10000 records in table MerchList and around 25
records in table tblAnalyst.


If I understood the requirements from your supplemental posting
correctly, this could be a solution:

UPDATE MerchList
SET AnalystID = MerchListID %
(SELECT COUNT(*) FROM tblAnalyst) + 1

This presumes that the AnalystIDs goes from 1 to 25 (or whatever)
without gaps. If there are gaps, or the id:s do not start at 1,
you could do:

CREATE TABLE #analystmap (id int IDENTITY(0, 1),
analystid int NOT NULL

INSERT #analystmap (analystid)
SELECT AnalystID FROM tblAnalyst ORDER BY newid()

UPDATE MerchList
SET AnalystID = a.analystid
FROM MerchList m
JOIN #analystmap a ON
m.MerchList % (SELECT COUNT(*) FROM #analystmap) = a.id

The ORDER BY newid() adds a certain randomness into the process, but
still merchants that are 25 ids apart will get the same analyst.

Disclaimer: as there was not test data included, I have not tested this.

Jul 20 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
6241
by: Dom Boyce | last post by:
Hi, I have a table containing analyst information, and each analyst has a unique ID (30 analysts, analyst IDs are 1,2,3,...29,30). I am creating a search form which feeds an underlying query with the search parameters, and returns the results in a subform. I have used a SELECT query to populate the "ComboAnalyst" combo box, and have added a UNION query to add an "All" option to the list:
2
2692
by: JC | last post by:
Hi, I have a database that imports 4 reports to my "data" table, each report has its own identifier. Then I have a table with Analysts with the report identifier that they are to be assigned to. What I need to do is loop the two tables so that an Analyst is assigned to each record in the "data" table based on the identifier. For example, I have one analyst that needs to be assigned to the "H" report records, one analyst that needs to...
2
1835
by: MLH | last post by:
Gentlemen: I have declared an array Dim MyTables(14) AS Long Now I want to assign values for MyTables(0) - MyTables(14) equal to the number of records in each table. Catch, I want the code to identify only those tables beginning with the letters "JA". Is this possible? Or, should I break down and manually type in all the table names?
3
6641
by: deko | last post by:
Is there any way to limit the number of records loaded into a ListBox? I looked at qdf.MaxRecords (to apply to the query that is the RowSource of the ListBox) but that only applies to ODBC data sources. I also looked at Tools > Options > Edit/Find and tried setting the "Don't display lists where more than this number of records read:" property, but that doesn't help. The List Box in question is supposed to allow scrolling/browsing of...
2
15710
by: dskillingstad | last post by:
I'm trying to assign a custom value to a textbox. Here's what I have. I've created a module and "default value" code for a textbox which generates a custom auto-number (yyyy-0000) when a New Record button is clicked. The code checks the table for the highest value and then assigns 1 and inserts the value. I have a second text box which needs the same type of custom auto-number which has to be generated from a second command button. ...
13
6578
by: MLH | last post by:
Suppose I have this simple SQL string... SELECT tblDrivers.DriverID, tblDrivers.DName FROM tblDrivers WHERE (((tblDrivers.DName) Like "N*")) ORDER BY tblDrivers.DriverID; And suppose that its not a saved querydef - just an SQL string that I cooked up in code and assigned to a global var strMySQL.
10
1676
by: Jeff | last post by:
Hey gang. i have a code that i will list. when varM = 8 or 16, the script works fine, and pulls the top 8 or top 16, but if it =32 or 64, it is only pulling the top 17 records from the DB. db is access and this is MS server. here is the code <% if varm = 8 then set admin6 = conn.execute("select top 8 username, iCHECK from
9
3393
by: raamay | last post by:
i have a table where the records are in the following fashion: firm w1 w3 w4 class abc ltd. b c d b bcd ltd. c c d c cde ltd. a d b a def ltd. d d d d as clearly indicated, the highest category among w1,w3 and w4 makes up the...
2
2139
by: Deb Mansfield | last post by:
I need to create a form that allows the user to enter the number of records they would like to work on and then assign those records to them. For example, have a form with open text box asking to enter the number of records to be assigned? The user enters any number (say 50) and the first 50 records in the queue are assigned to their current user ID. I will have up to 4 users at a time pulling their work. HELP!
0
8361
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8807
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8466
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7299
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6158
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5615
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4290
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2701
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1588
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.