Hi,
I have to create groups of people based on their drug consumption and then I have to track the movements between the groups over time.
So I have the following table (simplified for this task):
(SSN is the social security number of the consumer.)
First, I have to create groups. Every group is a combination of drugs, that people consume together. I have to find all combinations.
Next, I have to find the group that the consumer belongs to.
I tried to do it with a cursor based solution. It worked, but it is too slow. I have to find a faster one, because we have to pay for this data and the price depends on the runtime of the batch. I'm trying to find a set based solution, but it's really hard.
Does anyone have any idea?
Thanks,
Peter
PS: sorry for my poor English.
I have to create groups of people based on their drug consumption and then I have to track the movements between the groups over time.
So I have the following table (simplified for this task):
Code:
CONSUMPTION (
SSN VARCHAR2(9),
DRUG_ID VARCHAR2(9),
SELL_DATE DATE)
First, I have to create groups. Every group is a combination of drugs, that people consume together. I have to find all combinations.
Next, I have to find the group that the consumer belongs to.
I tried to do it with a cursor based solution. It worked, but it is too slow. I have to find a faster one, because we have to pay for this data and the price depends on the runtime of the batch. I'm trying to find a set based solution, but it's really hard.
Does anyone have any idea?
Thanks,
Peter
PS: sorry for my poor English.