PRMiller2
Technical User
- Jul 30, 2010
- 123
Hi gurus,
I need to design a report that provides the percentage of consultations that result in the prospect becoming a client. Consultations are recorded in an events table, but, when a prospect becomes a client, that event is NOT recorded. Instead, a value is changed in the client table (where both prospects and clients are stored). Here is my table structure:
When someone becomes a prospect, their record is added to the client table, and the value "-1" is set in intProspect.
When the prospect has a consultation, an event (fk_EventID of 7) is recorded in the events table along with, of course, the foreign key for their client record. Then, the "-1" value is removed from the intProspect field in the client's record, and a "-1" value is added for the intClient field.
Here's the SQL I currently have:
And here's an example of the results of that query:
As you can see, not all consultations result in clients. What's the best way to generate a percentage? This will be done in a report, so I'm not adverse to more than one query, even running them in VBA.
If worst comes to worst, we can always modify the database to have a "became client" event in addition to the intClient flag, though that may necessitate updating a number of records.
Thoughts?
I need to design a report that provides the percentage of consultations that result in the prospect becoming a client. Consultations are recorded in an events table, but, when a prospect becomes a client, that event is NOT recorded. Instead, a value is changed in the client table (where both prospects and clients are stored). Here is my table structure:
Code:
[b]eventOccurrence[/b]
pk_EventOccurrenceID
fk_EventID
eventDate
fk_ClientID
[b]client[/b]
pk_ClientID
intClient
intProspect
When someone becomes a prospect, their record is added to the client table, and the value "-1" is set in intProspect.
When the prospect has a consultation, an event (fk_EventID of 7) is recorded in the events table along with, of course, the foreign key for their client record. Then, the "-1" value is removed from the intProspect field in the client's record, and a "-1" value is added for the intClient field.
Here's the SQL I currently have:
Code:
SELECT eventOccurrence.eventDate, eventOccurrence.fk_EventID, client.intClient
FROM eventOccurrence
LEFT JOIN client ON eventOccurrence.fk_ClientID = client.pk_ClientID
WHERE eventOccurrence.fk_EventID)=7;
And here's an example of the results of that query:
Code:
[b]eventDate fk_EventID intClient[/b]
7/23/2010 7
12/21/2010 7 -1
12/16/2010 7 -1
11/9/2010 7 -1
10/29/2010 7 -1
12/26/2010 7 -1
7/31/2010 7
1/7/2011 7
1/18/2011 7 -1
As you can see, not all consultations result in clients. What's the best way to generate a percentage? This will be done in a report, so I'm not adverse to more than one query, even running them in VBA.
If worst comes to worst, we can always modify the database to have a "became client" event in addition to the intClient flag, though that may necessitate updating a number of records.
Thoughts?