Tickets sold during membership periods

Does anyone have an idea or a chunk of SQL that will show a membership that is active at the time of a ticket sale.  The challange I'm seeing is that there can be multiple memberships in TX_CUST_MEMBERSHIP even for the same membership orginiziation when a ticket is sold.  Has anyone solved this riddle?

--Tom

The Joins I'm trying are just not working correctly they add extra ticket records.

 

 

 

 

 

 

 

 

 

 

 

 

select

 

count (*)

from

 

dbo.T_SUB_LINEITEM as tsl with (nolock)

left join dbo.t_lineitem as tl with (nolock) on tsl.li_seq_no = tl.li_seq_no

 

 

left join dbo.t_order as tor with (nolock) on tl.order_no = tor.order_no

 

 

-- Comment the below out and you get a diffrent count

 

 

left join [dbo].vxs_cust_membership as M1 with (nolock)

 

 

on tor.customer_no = M1.customer_no and tl.create_dt <= M1.expr_dt and tl.create_dt >= M1.create_dt

 

 

and M1.memb_org_no = 1

Parents
  • Brian,

    Thanks for the code of this view. I'm on my blackberry right now so I may not be reading the code correctly. However, I can't see how this last membership view will help me find the current membership at the time of a ticket sale say 5 years ago. I'm trying to find the membership active at the time of all past ticket sales for all ticket sales. This is causing me trouble because there seem to be multiple membership records covering the same time period for a single membership organization. This of course is causing me to duplicate ticket records.

    --Tom

    mobile


    From: Tessitura Technical Forum <forums-technical@tessituranetwork.com>
    To: Thomas Brown
    Sent: Thu Feb 23 22:30:42 2012
    Subject: RE: [Tessitura Technical Forum] Tickets sold during membership periods

    Tom,

    This view will give you the most recent membership, with one per customer_no.  You are going to have to choose between membership organizations if you want one over the other.

     

     

    Brian Wilbur Grundstrom
    Composer
    1453 S Street NW
    Washington DC  20009
    213-2600-BWG [294]
    hm 202-232-3316
    cell 917-952-7957
    brian@brianwilbur.com
    www.brianwilbur.com

    www.brianwilbur.wordpress.com

    http://www.imdb.com/name/nm2505389/

     

     

     

    CREATE View [dbo].[lv_membership_most_recent]

    AS

     

     

    with last_membership as

    (select    

          a.customer_no,

          max(a.expr_dt) as expr_dt,

        sum(d.cont_amt) AS total_gift_amount

    from tx_cust_membership a (nolock)

    left JOIN TX_CONT_MEMB c (NOLOCK)  ON a.cust_memb_no = c.cust_memb_no

    left join T_CONTRIBUTION d (nolock)on c.cont_ref_no = d.ref_no

    where a.expr_dt = (select max(expr_dt) from tx_cust_membership where a.customer_no = customer_no) -- and a.memb_org_no = memb_org_no) want the last membership regardless of memb_org_type

      and a.memb_level not in ('LDW')

      and a.current_status <> 8 --deactivated

    GROUP BY a.customer_no

    )

    select

      b.cust_memb_no,

      b.customer_no,

      IsNull((c.fname + ' ' + c.lname), c.lname) as cust_name,

      mo.description as memb_org,

      b.memb_level,

      ml.description as memb_description,

      cs.description as current_status, 

      b.expr_dt,

      b.inception_dt,

      mc.description as category,

      b.ben_provider,

      a.total_gift_amount,

      b.memb_amt,

      b.recog_amt,

      b.AVC_amt,

      b.memb_org_no,

      b.current_status as current_status_no

    from last_membership a

    join TX_CUST_MEMBERSHIP b on a.customer_no = b.customer_no and a.expr_dt = b.expr_dt and b.current_status <> 8

    join T_CUSTOMER c on a.customer_no = c.customer_no

    Join t_memb_org mo on b.memb_org_no = mo.memb_org_no

    join T_MEMB_LEVEL ml on b.memb_level = ml.memb_level

    Join tr_current_status cs on b.current_status = cs.id

    Join tr_memb_level_category mc on ml.category = mc.id

     

    From: Tessitura Technical Forum [mailto:forums-technical@tessituranetwork.com] On Behalf Of Tom Brown
    Sent: Thursday, February 23, 2012 9:31 PM
    To: Brian W. Grundstrom
    Subject: [Tessitura Technical Forum] Tickets sold during membership periods

     

    Does anyone have an idea or a chunk of SQL that will show a membership that is active at the time of a ticket sale.  The challange I'm seeing is that there can be multiple memberships in TX_CUST_MEMBERSHIP even for the same membership orginiziation when a ticket is sold.  Has anyone solved this riddle?

    --Tom

    The Joins I'm trying are just not working correctly they add extra ticket records.

     

     

     

     

     

     

     

     

     

     

     

     

    select

     

    count (*)

    from

     

    dbo.T_SUB_LINEITEM as tsl with (nolock)

    left join dbo.t_lineitem as tl with (nolock) on tsl.li_seq_no = tl.li_seq_no

     

     

    left join dbo.t_order as tor with (nolock) on tl.order_no = tor.order_no

     

     

    -- Comment the below out and you get a diffrent count

     

     

    left join [dbo].vxs_cust_membership as M1 with (nolock)

     

     

    on tor.customer_no = M1.customer_no and tl.create_dt <= M1.expr_dt and tl.create_dt >= M1.create_dt

     

     

    and M1.memb_org_no = 1




    This message was sent automatically to you by www.tessituranetwork.com because you subscribed to the Tessitura Technical Forum. You may reply to this message to post to the Technical forum or visit the site to search, read and post to the forums. In the interest of keeping the forum posts from becoming cluttered, we encourage you to delete previous message text from your reply before sending. Thank you!




    This message was sent automatically to you by www.tessituranetwork.com because you subscribed to the Tessitura Technical Forum. You may reply to this message to post to the Technical forum or visit the site to search, read and post to the forums. In the interest of keeping the forum posts from becoming cluttered, we encourage you to delete previous message text from your reply before sending. Thank you!
Reply
  • Brian,

    Thanks for the code of this view. I'm on my blackberry right now so I may not be reading the code correctly. However, I can't see how this last membership view will help me find the current membership at the time of a ticket sale say 5 years ago. I'm trying to find the membership active at the time of all past ticket sales for all ticket sales. This is causing me trouble because there seem to be multiple membership records covering the same time period for a single membership organization. This of course is causing me to duplicate ticket records.

    --Tom

    mobile


    From: Tessitura Technical Forum <forums-technical@tessituranetwork.com>
    To: Thomas Brown
    Sent: Thu Feb 23 22:30:42 2012
    Subject: RE: [Tessitura Technical Forum] Tickets sold during membership periods

    Tom,

    This view will give you the most recent membership, with one per customer_no.  You are going to have to choose between membership organizations if you want one over the other.

     

     

    Brian Wilbur Grundstrom
    Composer
    1453 S Street NW
    Washington DC  20009
    213-2600-BWG [294]
    hm 202-232-3316
    cell 917-952-7957
    brian@brianwilbur.com
    www.brianwilbur.com

    www.brianwilbur.wordpress.com

    http://www.imdb.com/name/nm2505389/

     

     

     

    CREATE View [dbo].[lv_membership_most_recent]

    AS

     

     

    with last_membership as

    (select    

          a.customer_no,

          max(a.expr_dt) as expr_dt,

        sum(d.cont_amt) AS total_gift_amount

    from tx_cust_membership a (nolock)

    left JOIN TX_CONT_MEMB c (NOLOCK)  ON a.cust_memb_no = c.cust_memb_no

    left join T_CONTRIBUTION d (nolock)on c.cont_ref_no = d.ref_no

    where a.expr_dt = (select max(expr_dt) from tx_cust_membership where a.customer_no = customer_no) -- and a.memb_org_no = memb_org_no) want the last membership regardless of memb_org_type

      and a.memb_level not in ('LDW')

      and a.current_status <> 8 --deactivated

    GROUP BY a.customer_no

    )

    select

      b.cust_memb_no,

      b.customer_no,

      IsNull((c.fname + ' ' + c.lname), c.lname) as cust_name,

      mo.description as memb_org,

      b.memb_level,

      ml.description as memb_description,

      cs.description as current_status, 

      b.expr_dt,

      b.inception_dt,

      mc.description as category,

      b.ben_provider,

      a.total_gift_amount,

      b.memb_amt,

      b.recog_amt,

      b.AVC_amt,

      b.memb_org_no,

      b.current_status as current_status_no

    from last_membership a

    join TX_CUST_MEMBERSHIP b on a.customer_no = b.customer_no and a.expr_dt = b.expr_dt and b.current_status <> 8

    join T_CUSTOMER c on a.customer_no = c.customer_no

    Join t_memb_org mo on b.memb_org_no = mo.memb_org_no

    join T_MEMB_LEVEL ml on b.memb_level = ml.memb_level

    Join tr_current_status cs on b.current_status = cs.id

    Join tr_memb_level_category mc on ml.category = mc.id

     

    From: Tessitura Technical Forum [mailto:forums-technical@tessituranetwork.com] On Behalf Of Tom Brown
    Sent: Thursday, February 23, 2012 9:31 PM
    To: Brian W. Grundstrom
    Subject: [Tessitura Technical Forum] Tickets sold during membership periods

     

    Does anyone have an idea or a chunk of SQL that will show a membership that is active at the time of a ticket sale.  The challange I'm seeing is that there can be multiple memberships in TX_CUST_MEMBERSHIP even for the same membership orginiziation when a ticket is sold.  Has anyone solved this riddle?

    --Tom

    The Joins I'm trying are just not working correctly they add extra ticket records.

     

     

     

     

     

     

     

     

     

     

     

     

    select

     

    count (*)

    from

     

    dbo.T_SUB_LINEITEM as tsl with (nolock)

    left join dbo.t_lineitem as tl with (nolock) on tsl.li_seq_no = tl.li_seq_no

     

     

    left join dbo.t_order as tor with (nolock) on tl.order_no = tor.order_no

     

     

    -- Comment the below out and you get a diffrent count

     

     

    left join [dbo].vxs_cust_membership as M1 with (nolock)

     

     

    on tor.customer_no = M1.customer_no and tl.create_dt <= M1.expr_dt and tl.create_dt >= M1.create_dt

     

     

    and M1.memb_org_no = 1




    This message was sent automatically to you by www.tessituranetwork.com because you subscribed to the Tessitura Technical Forum. You may reply to this message to post to the Technical forum or visit the site to search, read and post to the forums. In the interest of keeping the forum posts from becoming cluttered, we encourage you to delete previous message text from your reply before sending. Thank you!




    This message was sent automatically to you by www.tessituranetwork.com because you subscribed to the Tessitura Technical Forum. You may reply to this message to post to the Technical forum or visit the site to search, read and post to the forums. In the interest of keeping the forum posts from becoming cluttered, we encourage you to delete previous message text from your reply before sending. Thank you!
Children