Comapring rows of a table to multple rows within the same table

M

Mozee

Hi,

I have the following data which I have been tasked with identifying a
primary case for each customer. Unfortunately the data contains duplicate
records such as Case 1 and 2. I would be extremely grateful if you could tell
me how can I compare all the rows related to Customer 1 and flag a case as
the primary case.

CaseID, CustomerID, PrimaryStatus, SecondaryStatus, GroupA, GroupB
1,1,New, Unassigned, RU, HK
2,1,New, Unassigned, RU, HK
3,1,In Progress, Normal Review, RU, HK
4,1,New, Unassigned, IN, UK
5,2,New, Assigned, JP,
6,2,In Progress, Special Review, BR, HK
7,2,Complete, Success, , US
8,2,Complete, Success, , HK


I have tried a number of queries and even used Recordsets as part of VBA
procedures but dont seem to be able to figure out how I can compare the cases
for a customer.

Customer 2 scenario is more complicated as I need to be able to pick case 5
and 6 as primary cases. The reason for this is that values in GroupA are
exclusive where is values in GroupB are based on a ranking for example HK is
higher than UK and UK is higher than US. Case 6 is chosen over case 8 even
though they share the same Group B value as Case 6 has a Group A value which
is exclusive.

Going back to the Customer 1, the cases that should be flagged as primary
are 3 and 4. This is because even though case 3 has the same GroupA and B
values, it has progressed further in the workflow. Case 4 is selected as well
as it has a group A value different from case 3. If it had the same value
then case 3 could have been excluded.

Can I write a query to this in SQL in Access and how will this look OR do I
code something in VBA to do this and how would that look?

Please help.

Many thanks,
 
P

PieterLinden via AccessMonster.com

Mozee,
please define what "primary" means (well, in the way you are using it). In
addition to your sample data, explain how you determine which cases are
"primary" -- what is the business rule that determines this?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top