code: func (ssa *SQLStorageAuthority) countCertificates(db dbSelector, domain string, earliest, latest time.Time, query string) (int, error) {
  	var serials []string
  	_, err := db.Select(
  		&serials,
  		query,
  		map[string]interface{}{
  			"reversedDomain": ReverseName(domain),
  			"earliest":       earliest,
  			"latest":         latest,
  		})
  	if err == sql.ErrNoRows {
  		return 0, nil
  	} else if err != nil {
  		return 0, err
  	}
  
  	// Deduplicate serials returning a count of unique serials
  	serialMap := make(map[string]struct{}, len(serials))
  	for _, s := range serials {
  		serialMap[s] = struct{}{}
  	}
  	return len(serialMap), nil
  }
docs: // countCertificates returns, for a single domain, the count of certificate
  // issuances in the given time range for that domain using the
  // provided query assumed to be either `countCertificatesExactSelect`,
  // or `countCertificatesSelect`.