SELECT
  CP.ClientID,
  CP.ProductID,
  CP.ClientProductID,
  CC.EntryType,
  CC.StartDate,
  CC.NextIncreaseDate,
  CC.CoverValue,
  CC.FreeHours,
  CC.FreeVisits,
  CC.ValueResetMonths,
  CC.HoursResetMonths,
  CC.VisitsResetMonths
FROM
  taClientProductCover AS CC
    INNER JOIN (
      SELECT M.ClientProductID, M.StartDate
      FROM taClientProductCover AS M
      WHERE
        (M.ClientProductID = @nClientProductID) AND
        (M.StartDate = (
          SELECT MAX(N.StartDate)
          FROM taClientProductCover AS N
          WHERE
            (N.ClientProductID = M.ClientProductID) AND
            (N.StartDate <= @aAttendanceDate)
        ))
    ) AS X USING (ClientProductID, StartDate)
    INNER JOIN taClientProducts AS CP USING (ClientProductID)