9 Replies Latest reply: Aug 10, 2017 3:01 PM by Andrew Walker RSS

    Multiple WHEREs, ORs, ANDs

    Ben Petosa

      Hello Everyone,

       

      At the end of my load script, I have the following resident load with multiple criteria at the end. The AND statement at the end makes sure that the same email isn't sent out 2 weeks in a row ("isnull" is in case they never went out). All the statements above the AND seem to work fine, but the AND statement won't work unless I comment the rest of them out. I am hoping it is just a simple syntax error, and appreciate any help that comes my way.

       

      Resident:

      Load

           segment_id,

          event,

          funded,

          is_published,

          Goal,

           Published_Date,

           Expiration_Date,

          Title,

          "Contracted Email Features",

          "Current Email Features",

          launch_date,

          is_feature

         

      RESIDENT QVDData

       

      WHERE (Published_Date > TODAY()-365)

      OR (Published_Date >= Today() and Published_Date <= $(thisweek))

      OR (Expiration_Date >= Today() and Expiration_Date < weekstart(TODAY(), 2, 0))

      OR ("Contracted Email Features" - "Current Email Features" > 0)

      OR (event/Goal <.3 and Published_Date<TODAY()-90)

      AND (launch_date < TODAY() - 7  or isnull(launch_date))

      ;

       

      DROP TABLE QVDData

      ;