I would like to return those records where Action = "Change Plan" for 3 months in a row (past three months) for all the users.
These are the users where we have to change their plan because it has been recommended to do so three times in a row.
One record would look like this:
Recommended_Plan Action USERID Date Current Plan
---------------- ------ ------ ------ ------------
RAS Change AUT1CXG 04/01/2003 VPN
Here is how I did it, it works, but it is definetely not the way to do it because what if i wanted to return records where the value occurs 8 times in a row? Do I add 8 of the same tables?
sQ_Plan_Change is One Query. I just added this query to a subquery 3 times.
SELECT T_Users.USERID, T_Users.LastName, T_Users.FirstName
FROM ((sQ_Plan_Change RIGHT JOIN T_Users ON sQ_Plan_Change.USERID = T_Users.USERID) LEFT JOIN sQ_Plan_Change AS sQ_Plan_Change_1 ON T_Users.USERID = sQ_Plan_Change_1.USERID) LEFT JOIN sQ_Plan_Change AS sQ_Plan_Change_2 ON T_Users.USERID = sQ_Plan_Change_2.USERID
WHERE (((sQ_Plan_Change.Date)=#2/1/2004#) AND ((sQ_Plan_Change_1.Date)=#3/1/2004#) AND ((sQ_Plan_Change_2.Date)=#4/1/2004#) AND ((sQ_Plan_Change.Action)="Change Plan") AND ((sQ_Plan_Change_1.Action)="Change Plan") AND ((sQ_Plan_Change_2.Action)="Change Plan"));
What is the most effective way to do this?
These are the users where we have to change their plan because it has been recommended to do so three times in a row.
One record would look like this:
Recommended_Plan Action USERID Date Current Plan
---------------- ------ ------ ------ ------------
RAS Change AUT1CXG 04/01/2003 VPN
Here is how I did it, it works, but it is definetely not the way to do it because what if i wanted to return records where the value occurs 8 times in a row? Do I add 8 of the same tables?
sQ_Plan_Change is One Query. I just added this query to a subquery 3 times.
SELECT T_Users.USERID, T_Users.LastName, T_Users.FirstName
FROM ((sQ_Plan_Change RIGHT JOIN T_Users ON sQ_Plan_Change.USERID = T_Users.USERID) LEFT JOIN sQ_Plan_Change AS sQ_Plan_Change_1 ON T_Users.USERID = sQ_Plan_Change_1.USERID) LEFT JOIN sQ_Plan_Change AS sQ_Plan_Change_2 ON T_Users.USERID = sQ_Plan_Change_2.USERID
WHERE (((sQ_Plan_Change.Date)=#2/1/2004#) AND ((sQ_Plan_Change_1.Date)=#3/1/2004#) AND ((sQ_Plan_Change_2.Date)=#4/1/2004#) AND ((sQ_Plan_Change.Action)="Change Plan") AND ((sQ_Plan_Change_1.Action)="Change Plan") AND ((sQ_Plan_Change_2.Action)="Change Plan"));
What is the most effective way to do this?