jkulvich

SQLTask

Sep 24th, 2018
51
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. SELECT (
  2.   SELECT "Email"
  3.   FROM Activities_Participants
  4.   WHERE Activities."ActivityID" == ActivityID
  5. ) AS "Email",
  6. (
  7.   SELECT "ActivityDate"
  8.   FROM Activities_Participants
  9.   WHERE Activities."ActivityID" == ActivityID
  10. ) AS "Date",
  11. "Name",
  12. "Type",
  13. "SubType" +
  14.   IF(
  15.     "Type" IN('TypeA', 'TypeB', 'TypeC') AND
  16.     "SubType" NOT IN('TypeC'),
  17.       ' Needed_Activity',
  18.       '') +
  19.   IF(
  20.     SELECT "ActivityDate"
  21.     FROM Activities_Participants < getdate(),
  22.       ' Net_New_Activity',
  23.       '') AS "SubType"
  24. WHERE YEAR(getdate()) == (
  25.   SELECT YEAR("ActivityDate")
  26.   FROM Activities_Participants
  27.   WHERE Activities."ActivityID" == "ActivityID"
  28. )
RAW Paste Data