SELECT
  StartDate,
  IF((NextIncreaseDate IS NULL) OR (NextIncreaseDate = '0000-00-00'), '-', NextIncreaseDate) AS NextIncreaseDate,
  IF(CoverValue > 0.0,
    IF(ValueResetMonths <= 0, CONCAT('R ', FORMAT(CoverValue, 2), ' once off'),
      CONCAT('R ', FORMAT(CoverValue, 2), ' every', IF(ValueResetMonths = 1, '', CONCAT(' ', FORMAT(ValueResetMonths, 0))), ' month', IF(ValueResetMonths > 1, 's', ''))),
    IF(CoverValue < 0.0, 'Unlimited Cover Value', 'none')
  ) AS CoverValue,
  IF(FreeHours > 0.0,
    IF(HoursResetMonths <= 0, CONCAT(FORMAT(FreeHours, 0), ' hour', IF(FreeHours > 1, 's', ''), ' once off'),
      CONCAT(FORMAT(FreeHours, 0), ' hour', IF(FreeHours > 1, 's', ''), ' every', IF(HoursResetMonths = 1, '', CONCAT(' ', FORMAT(HoursResetMonths, 0))), ' month', IF(HoursResetMonths > 1, 's', ''))),
    IF(FreeHours < 0.0, 'Unlimited Free Hours', 'none')
  ) AS FreeHours,
  IF(FreeVisits > 0.0,
    IF(VisitsResetMonths <= 0, CONCAT(FORMAT(FreeVisits, 0), ' visit', IF(FreeVisits > 1, 's', ''), ' once off'),
      CONCAT(FORMAT(FreeVisits, 0), ' visit', IF(FreeVisits > 1, 's', ''), ' every', IF(VisitsResetMonths = 1, '', CONCAT(' ', FORMAT(VisitsResetMonths, 0))), ' month', IF(VisitsResetMonths > 1, 's', ''))),
    IF(FreeVisits < 0.0, 'Unlimited Free Visits', 'none')
  ) AS FreeVisits
FROM
  taClientProductCover
WHERE
  (ClientProductID = @nClientProductID)
ORDER BY
  StartDate
