locked
Linking Tables together RRS feed

  • Question

  • I want to create a report that show Contact and their Activities (both open and closed) and Marketing Lists.

    I am having a problem determing which tables (Activities, Marketing List) these are and the fields that link them all together.

    Is there no document that show the tables and the fields they link on?  The LogicalDBDiagram is close but not quite complete.

    Thank you
    Wednesday, April 1, 2009 1:46 PM

Answers

  • For Activities, check the ActivityParty - that will show who was attached to an email - (the contact may be attached multiple times/ways - as a sender/recepient/cc/bcc etc.)  (you can extend this to pick up the other entity types you need to report on.

    select distinct 
    top 10
    c.contactid, 
    c.fullname,
    Party.ParticipationtypemaskName,
    Pointer.ActivityTypeCodeName,
    Email.Subject
    from FilteredContact c
    Left Join FilteredActivityParty Party 
    on Party.PartyId = c.ContactId
    Join FilteredActivityPointer Pointer
    On Party.ActivityId = Pointer.ActivityId
    Left Join FilteredEmail Email
    on Email.ActivityId = Party.ActivityId
    


    and for the Marketing lists - its the lists and listmembers you're looking for

    select distinct 
    top 10
    c.contactid, 
    c.fullname,
    List.ListName
    from FilteredContact c
    Left Outer Join FilteredListMember Member
    on Member.entityid = c.contactid
    Join FilteredList List
    On Member.ListId = List.ListId
    order by fullname
     

    Scott Sewell, CustomerEffective | http:\\blog.CustomerEffective.com | Twitter:@ScottSewell
    Wednesday, April 1, 2009 3:20 PM
    Moderator
  • They're all in the same tables - just check state/status (status/statusreason)


    Scott Sewell, CustomerEffective | http:\\blog.CustomerEffective.com | Twitter:@ScottSewell
    • Marked as answer by Matthews_416 Thursday, April 2, 2009 11:44 AM
    Wednesday, April 1, 2009 7:58 PM
    Moderator

All replies

  • For Activities, check the ActivityParty - that will show who was attached to an email - (the contact may be attached multiple times/ways - as a sender/recepient/cc/bcc etc.)  (you can extend this to pick up the other entity types you need to report on.

    select distinct 
    top 10
    c.contactid, 
    c.fullname,
    Party.ParticipationtypemaskName,
    Pointer.ActivityTypeCodeName,
    Email.Subject
    from FilteredContact c
    Left Join FilteredActivityParty Party 
    on Party.PartyId = c.ContactId
    Join FilteredActivityPointer Pointer
    On Party.ActivityId = Pointer.ActivityId
    Left Join FilteredEmail Email
    on Email.ActivityId = Party.ActivityId
    


    and for the Marketing lists - its the lists and listmembers you're looking for

    select distinct 
    top 10
    c.contactid, 
    c.fullname,
    List.ListName
    from FilteredContact c
    Left Outer Join FilteredListMember Member
    on Member.entityid = c.contactid
    Join FilteredList List
    On Member.ListId = List.ListId
    order by fullname
     

    Scott Sewell, CustomerEffective | http:\\blog.CustomerEffective.com | Twitter:@ScottSewell
    Wednesday, April 1, 2009 3:20 PM
    Moderator
  • I failed to mention, you'll want to adjust the join types (outer/not) to get the results you're needing for your report.
    Scott Sewell, CustomerEffective | http:\\blog.CustomerEffective.com | Twitter:@ScottSewell
    Wednesday, April 1, 2009 3:26 PM
    Moderator
  • Thanks for the information.  I do have one more question however. 

    On the Activity, I will want to report on both the Open and Closed items.
    Where are the Closed items, is that the History?
    Thank you
    Wednesday, April 1, 2009 7:56 PM
  • They're all in the same tables - just check state/status (status/statusreason)


    Scott Sewell, CustomerEffective | http:\\blog.CustomerEffective.com | Twitter:@ScottSewell
    • Marked as answer by Matthews_416 Thursday, April 2, 2009 11:44 AM
    Wednesday, April 1, 2009 7:58 PM
    Moderator