Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Calculate when someone's membership is new, current or a lapsed membership per term

Status
Not open for further replies.

kernal

Technical User
Feb 27, 2001
415
US
I need a select statement that calculates when someone's membership is new, continuing or a lapsed membership per term

Example of one person in the table:

Table:

term person_id type
1078 1 New Member Status: First term they purchased a membership
1084 1 Continuing Status
1086 1 Continuing Status
1088 1 Continuing Status
1094 1 Lapsed Status: Membership expired in 1088 and did not renew (only want to count the person as lapsed for this term since it is the next term after their membership expired)
1096 Don't want to count: Do not want to count since this isn't the next term after the membership expired
1098 Don't want to count: Do not want to count since this isn't the next term after the membership expired
1104 1 Continuing Status: They renewed their membership this term
1106 1 Continuing Status
1108 1 Continuing Status
1114 1 Lapsed Status Again:
1116 Don't want to count: Do not want to count since this isn't the next term after the membership expired again

I hope I have provided all of the data needed.

Help is appreciated.

Thanks
 
I presume the data under Type is not actually stored
anywhere and is just your own description of the various membership states, otherwise you would just count
where type like 'NEW%' , 'Continuing%' , 'Lapsed%' etc ....

If my presumption is correct what is actually stored in the table for the entries above that indicate membership status?

Please also indicate in your answer what your expected output is to be.


In order to understand recursion, you must first understand recursion.
 
Remember that you can always write 3 separate queries ("new", "continuing", and "lapsed") and do a UNION between them. This technique is always an option when the table is relatively small and you don't mind doing 3 passes across it. If the table is large, then a single query with a complex WHERE clause is probably better.

==================================
adaptive uber info galaxies (bigger, better, faster, and more adept than agile big data clouds)


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top