SELECT
  AP.AttendanceTypeID,
  TRIM(AT.AppointmentType) AS AppointmentType,
  AP.BillingDate
FROM
  tbAppointments AS AP
    INNER JOIN tbAppointmentTypes AS AT ON (AT.AttendanceTypeID = AP.AttendanceTypeID)
    INNER JOIN taClientBranchProducts AS BP ON (BP.ClientBranchProductID = AP.ClientBranchProductID)
WHERE
  (BP.ClientProductID = @nClientProductID) AND
  (AP.AppointmentStage = 'Authorised') AND
  (AT.ProductCategory = 'SaaS')
ORDER BY
  AT.AppointmentType,
  AP.BillingDate
