SELECT
  CC.ClientCoverID,
  CC.ClientID,
  CC.StartDate,
  CC.NextIncreaseDate,
  CC.IncreasePercentage,
  CC.CoverValue,
  CC.FreeHours,
  CC.FreeVisits,
  CC.ValueResetMonths,
  CC.HoursResetMonths,
  CC.VisitsResetMonths,
  CS.GroupName
FROM 
  taClientCover AS CC
    LEFT JOIN taClients AS CS ON (CS.ClientID = CC.ClientID)
WHERE 
  (CS.ClientStatus = 1) AND 
  (CC.CoverValue IS NOT NULL) AND 
  (CC.CoverValue > 0) AND 
  (CC.ValueResetMonths IS NOT NULL) AND 
  (CC.ValueResetMonths > 0) AND 
  (CC.NextIncreaseDate IS NOT NULL) AND 
  (CC.NextIncreaseDate <> '0000-00-00') AND 
  (CC.NextIncreaseDate <= @aEffectiveDate) 
ORDER BY 
  CC.ClientID




