{
  "sendNotification": true,
  "notificationAddresses": [
    "userEmail@example.org" 
  ],
  "format": "SQL_TSV_ZIP",
  "sql": "
  SELECT
    \"year\",
    GBIF_EEARGCode(
      1000,
      decimalLatitude,
      decimalLongitude,
      COALESCE(coordinateUncertaintyInMeters, 1000)
    ) AS eeaCellCode,
    classKey,
    class,
    speciesKey,
    species,
    COUNT(*) AS occurrences,
    MIN(COALESCE(coordinateUncertaintyInMeters, 1000)) AS minCoordinateUncertaintyInMeters,
    MIN(GBIF_TemporalUncertainty(eventDate)) AS minTemporalUncertainty,
    IF(ISNULL(classKey), NULL, SUM(COUNT(*)) OVER (PARTITION BY classKey)) AS classCount
  FROM
    occurrence
  WHERE 
    occurrenceStatus = 'PRESENT'
    AND speciesKey IN (
      1003567,
      1003574,
      1003642,
      1003614,
      1003625,
      1003588,
      1003611,
      10329226,
      4559524,
      1010304,
      7552441,
      4985433,
      1010587,
      1008388,
      1007770,
      4984866,
      1006399,
      4984953)
    AND continent = 'EUROPE'
    AND \"year\" >= 1900
    AND hasCoordinate = TRUE    
    AND speciesKey IS NOT NULL
    AND NOT ARRAY_CONTAINS(issue, 'ZERO_COORDINATE')
    AND NOT ARRAY_CONTAINS(issue, 'COORDINATE_OUT_OF_RANGE')
    AND NOT ARRAY_CONTAINS(issue, 'COORDINATE_INVALID')
    AND NOT ARRAY_CONTAINS(issue, 'COUNTRY_COORDINATE_MISMATCH')
    AND (
      LOWER(identificationVerificationStatus) NOT IN (
        'unverified',
        'unvalidated',
        'not validated',
        'under validation',
        'not able to validate',
        'control could not be conclusive due to insufficient knowledge',
        'uncertain',
        'unconfirmed',
        'unconfirmed - not reviewed',
        'validation requested'
        )
      OR identificationVerificationStatus IS NULL
    )
  GROUP BY
    \"year\",
    eeaCellCode,
    classKey,
    class,
    speciesKey,
    species
  ORDER BY
    \"year\" DESC,
    eeaCellCode ASC,
    speciesKey ASC;
  "
}
