SQL code to get phone number, email address, from On Account Tracking Report?

Hi! I'm trying to write an On Account Tracking report, but I'm having a serious problem with duplication. I'm getting one row for each unique customer/phone number/email combination. Any suggestions or ideas? Thanks! :)

Parents
  • My suggestion is to create your own custom view using the logic you want to apply to determine an e-mail to use as FT_GET_Primary_Eaddress can be slow and doesn't return an e-mail if a primary was not assigned.

    Here is what we use and in a comparable run it ran 13 seconds faster than the function against the same data set.

      Create view [dbo].[LV_MBA_PrimaryEmail] as
      Select customer_no , Email , isPrimary,eaddress_no  from
      ( Select  customer_no , address as Email, isnull(primary_ind,'N') as isPrimary , ea.eaddress_no
      ,ROW_NUMBER () over (partition by Customer_No order by isnull(Primary_ind,'N') Desc,ea.eaddress_type, lastuse desc, ea.create_dt desc, ea.eaddress_no desc) as SeqNo
      from T_EADDRESS as EA inner join TR_EADDRESS_TYPE as ET on ea.eaddress_type  = et.id
      left outer join LV_MBA_EmailFreq as EF on ef.eaddress_no =ea.eaddress_no
      where et.email_ind = 'Y' and address !='<temporary>'  ) as E where SeqNo = 1

  • LV_MBA_EmailFreq has me intrigued

Reply Children