I have a very inefficient select expert formula - it takes way too long. This was the original query:
(({Transaction_History.Social_Code} = "047" or
({Transaction_History.Social_Code} = "075" and
{CONTACT.C_ADR_1} = "Fidelity Investment Advisor Group") and not ({Rep_Profile.Territory} in ["85", "89", "90", "88", "00"] and
{Transaction_History.Fund} in "0100" to "0399"
then I had to add an "or" statement
or
({Transaction_History.Fund} = "647" and
{Transaction_History.Social_Code} ="057" and
{Transaction_History.Dealer_Number} = "3705" and
{Transaction_History.Account_No} in ["9083852112", "9083852211"])
this is what I ended up with:
(({Transaction_History.Social_Code} = "047" or
({Transaction_History.Social_Code} = "075" and
{CONTACT.C_ADR_1} = "Fidelity Investment Advisor Group")
or
({Transaction_History.Fund} = "647" and
{Transaction_History.Social_Code} ="057" and
{Transaction_History.Dealer_Number} = "3705" and
{Transaction_History.Account_No} in ["9083852112", "9083852211"])
and
not ({Rep_Profile.Territory} in ["85", "89", "90", "88", "00"] and
{Transaction_History.Fund} in "0100" to "0399"
Once I added the "or" statement, the query slowed to a crawl. I am sure there is a better way of writing this.
(({Transaction_History.Social_Code} = "047" or
({Transaction_History.Social_Code} = "075" and
{CONTACT.C_ADR_1} = "Fidelity Investment Advisor Group") and not ({Rep_Profile.Territory} in ["85", "89", "90", "88", "00"] and
{Transaction_History.Fund} in "0100" to "0399"
then I had to add an "or" statement
or
({Transaction_History.Fund} = "647" and
{Transaction_History.Social_Code} ="057" and
{Transaction_History.Dealer_Number} = "3705" and
{Transaction_History.Account_No} in ["9083852112", "9083852211"])
this is what I ended up with:
(({Transaction_History.Social_Code} = "047" or
({Transaction_History.Social_Code} = "075" and
{CONTACT.C_ADR_1} = "Fidelity Investment Advisor Group")
or
({Transaction_History.Fund} = "647" and
{Transaction_History.Social_Code} ="057" and
{Transaction_History.Dealer_Number} = "3705" and
{Transaction_History.Account_No} in ["9083852112", "9083852211"])
and
not ({Rep_Profile.Territory} in ["85", "89", "90", "88", "00"] and
{Transaction_History.Fund} in "0100" to "0399"
Once I added the "or" statement, the query slowed to a crawl. I am sure there is a better way of writing this.