SELECT
  CP.ClientID,
  CS.FinNumber,
  CS.GroupName,
  CC.ClientProductID,
  PR.ProductCategory,
  PR.ProductName,
  PR.ServiceCoverIncreasePercentage,
  CC.StartDate,
  CC.NextIncreaseDate,
  fnClientProductRetainer(CP.ClientProductID, CC.StartDate) AS Retainer,
  CC.CoverValue,
  (ROUND(CC.CoverValue * (100.0 + PR.ServiceCoverIncreasePercentage) / 100.0, -1) - CC.CoverValue) AS Increase,
  ROUND(CC.CoverValue * (100.0 + PR.ServiceCoverIncreasePercentage) / 100.0, -1) AS NewCoverValue,
  CC.FreeHours,
  CC.FreeVisits,
  CC.ValueResetMonths,
  CC.HoursResetMonths,
  CC.VisitsResetMonths
FROM
  taClientProductCover AS CC
    INNER JOIN taClientProducts AS CP ON (CP.ClientProductID = CC.ClientProductID)
    INNER JOIN taClients AS CS ON (CS.ClientID = CP.ClientID)
    INNER JOIN taProducts AS PR ON (PR.ProductID = CP.ProductID)
WHERE
  (CS.ClientStatus = 1) AND
  (CC.CoverValue IS NOT NULL) AND
  (CC.CoverValue > 0) AND
  (CC.NextIncreaseDate IS NOT NULL) AND
  (CC.NextIncreaseDate <> '0000-00-00') AND
  (CC.NextIncreaseDate <= @aEffectiveDate) AND
  (CC.ClientProductID IN (@nClientProductID)) AND
  (PR.ServiceCoverIncreasePercentage > 0.0)
ORDER BY
  CP.ClientID, CP.ClientProductID