Dear Experts,
I am trying to make a query which returns all contacts who have referred at least 3 contacts within the last XXX days. In this example, I have entered the value of 360 (1 year). I have not even tried to figure out how to calculate the total number of referrals given becuase it gets really weird then.
It does not pull the values correctly...The query I am posting LOOKS like it works...but it doesn't. It's just not accurate and I don't know what I have done wrong. Please view line 17 where the code is 'WHERE Referred_By = Contact_Auto_ID)' - notice that the ')' character closes the select statement. If I put this anywhere else, I get a really jacked up set of data... Just an example of one problem I am having.
Here is how my table looks (I have taken out some of the columns which don't matter like names & phone number columns... you can see those in the select statement on the link)
[Contacts].Contacts
--------------------
Contact_Auto_ID (pk, int)
Date_Added (smalldatetime)
Referred_By (int - fk to Contact_Auto_ID in this table)
The column 'Referred_By' must be related to Contact_Auto_ID so that's why it's a FK to a column in the same table... There is a default value in Contact_Auto_ID of 0. That's how we have Referred_By set to 0 in the columns which weren't referred by another contact.
Another weird thing..in the current query, the column 'PhoneHome' has a value of null and it shows the record. If I enter a phone number, that record goes away. I have NO IDEA WHY!!!
I have been working with this for several hours now and still no luck... Please help!
Here is the link to my query:
http://75.33.104.230/code/query.aspx
Our community of experts have been thoroughly vetted for their expertise and industry experience.
The Most Valuable Expert award recognizes technology experts who passionately share their knowledge with the community, demonstrate the core values of this platform, and go the extra mile in all aspects of their contributions. This award is based off of nominations by EE users and experts. Multiple MVEs may be awarded each year.
The Distinguished Expert awards are presented to the top veteran and rookie experts to earn the most points in the top 50 topics.