Select
      'Sowing',
      m49,
      aezName,
      countryName,
      cropId,
      cropName,
      allYear,
      CASE WHEN allYear = 'yes' THEN DATE(currentYear,1,1) 
           ELSE CASE WHEN earlySowingMonth IS NULL THEN NULL 
                     ELSE DATE(currentYear,earlySowingMonth,earlySowingDay)
                 END 
      END as start_date,
      CASE WHEN allYear = 'yes' THEN DATE(currentYear,12,31)
           ELSE CASE WHEN lateSowingMonth IS NULL THEN NULL
                          WHEN lateSowingMonth IS NOT NULL AND lateSowingMonth < earlySowingMonth THEN
                                DATE(currentYear + 1 ,lateSowingMonth,lateSowingDay)
                          ELSE DATE(currentYear,lateSowingMonth,lateSowingDay)
                 END
       END as end_date,
      growingPeriod,
      growingValue,
      sowingRateUnit,
      sowingRateValue,
      lastUpdated,
      currentYear,
      CASE WHEN allYear = 'yes' then 'All Year' 
            ELSE CONCAT(FORMAT_DATE('%b %d', CASE WHEN allYear = 'yes' THEN DATE(currentYear,1,1) 
           ELSE CASE WHEN earlySowingMonth IS NULL THEN NULL 
                     ELSE DATE(currentYear,earlySowingMonth,earlySowingDay)
                 END 
      END), ' to ' ,FORMAT_DATE('%b %d', CASE WHEN allYear = 'yes' THEN DATE(currentYear,12,31)
           ELSE CASE WHEN lateSowingMonth IS NULL THEN NULL
                          WHEN lateSowingMonth IS NOT NULL AND lateSowingMonth < earlySowingMonth THEN
                                DATE(currentYear + 1 ,lateSowingMonth,lateSowingDay)
                          ELSE DATE(currentYear,lateSowingMonth,lateSowingDay)
                 END
       END)) 
       END AS period
From 
(SELECT row_number() over(partition by aezId order by  PARSE_DATE('%d/%m/%Y',lastUpdated ) desc) as row,
       *
FROM `fao-maps.fao_crop_calendar.fct_crop_calendar_cleaned`
Where cropId = '0303'
      AND m49=834) aux
Where row=1