Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Query to Assign Value based on size of group

Status
Not open for further replies.

Frenstall

Technical User
Mar 23, 2005
2
CA
Hello, I am trying to automate an Excel/hand process and can't get my head around how to solve this one situation:

I have a table with fields: company, part, defect

I want to give a company a score (-1) if they have a part & a defect of a certain type. The part and defect can exist multiple times but will be counted as one defect. BUT if there are five or more part-defect groups then they will be given a score of -5.

As pseudo code:

tbl[co,prt,def]
int[] score[company,prt,score,count]

for all values in table
for all values in score[]
if score.prt = tbl.prt then
score.count++
end if
end for

for all values in score[]
if score.count >= 5 then
score.score = -5
elseif score.count > 0 then
score.score = -1
else
score.score = 0
end if
end for

then total all the scores for one company and store it in a table

Hopefully this describes what i'm trying to do, again I am not great at Access so I am not even sure if a SQL query is the best method. Anyways, any input is greatly appreciated.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top