Confirm SQL Code for List Manager

Hi guys,

We are trying to make a list which shows a list of constituents with at least 1 order in ticket history, and their account creation date is within last 30 days from today. 

Could you please confirm if this SQL code is correct?

Select A.customer_no
From T_CUSTOMER A left join T_TICKET_HISTORY B
ON A.customer_no = B.customer_no
Where A.create_dt >= dateadd(DAY,-30,getdate()) and B.order_no is not null and A.inactive = 1
If it is not correct, could you please provide your inputs?
Thank you very much,
Tom Nguyen
  • Hi Tom,
    You'll most likely need to "select distinct A.customer_no" in order to not have duplicates.
    also if you make an inner join (or just join) instead of left join, the condition "and B.order_no is not null" becomes superflous - this last part doesn't affect the outcome though.

    Best wishes

    Jacob