×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

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

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

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

(OP)
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

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

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.

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

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)


Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close