SELECT

  -- Presentation Details
  PT.PresentationID,
  PT.CalendarID,
  CONCAT('with ', PT.ContactFirstName) AS SubjectName,
  PT.ContactFirstName,
  PT.ContactSurname,
  PT.ContactEmail,
  PT.PresentationProducts,
  PT.AttendanceDate,
  PT.AttendanceTime,
  PT.Duration,
  -- IF(TRIM(COALESCE(PT.CalendarID, '')) = '', '', CONCAT('<tr><td class="label">CMS Calendar : </td><td><a href="<#CMS_URI>calendar/view_entry.php?id=', PT.CalendarID, '">CMS Calendar Event</a></td></tr>')) AS CMSCalendarLink,
  '' AS CMSCalendarLink,
  IF(TRIM(COALESCE(PT.OutlookEventWebLink, '')) = '', '', CONCAT('<tr><td class="label">Outlook : </td><td><a href="', PT.OutlookEventWebLink, '">Outlook Event</a></td></tr>')) AS OutlookLink,

  -- Prospect Details
  PT.ProspectID,
  PS.ProspectName,

  -- Branch Manager
  BR.BranchManagerID,

  -- Regional Product Managers
  NULL AS RegionalProductManagerID,

  -- Product Executives
  NULL AS ProductExecutiveID,

  -- Allocated Consultants
  PT.ConsultantID,

  -- Sales People
  NULL AS SalesPersonID,

  -- Branch Administrators
  ( SELECT GROUP_CONCAT(DISTINCT ConsultantID)
    FROM taBranchStructure
    WHERE
      (BranchID = PS.LabourNetBranchID) AND
      (Description LIKE '%Branch Administrator%')
  ) AS BranchAdministratorID,

  -- Debtor Clerk
  NULL AS DebtorClerkID
FROM
  taPresentation AS PT
    LEFT JOIN taProspect AS PS ON (PS.ProspectID = PT.ProspectID)
    LEFT JOIN taBranches AS BR ON (BR.BranchID = PS.LabourNetBranchID)
WHERE
  (PT.PresentationID = @nPresentationID)
