SELECT * 
FROM `fao-maps-review.fao_famews.vw_traps_lat_lon` 
where (@dim_country = 'All Countries' or country=@dim_country) and 
      (
       (@period = "l1w" and date >= date_add(DATE_TRUNC(current_date(), WEEK(SUNDAY)), interval -7 day) and date <= DATE_TRUNC(current_date(), WEEK(SUNDAY))) OR
       (@period = "l1m" and date >= date_add(DATE_TRUNC(current_date(), month), interval -1 month) and date < DATE_TRUNC(current_date(), month)) OR
       (@period = "l3m" and date >= date_add(DATE_TRUNC(current_date(), month), interval -3 month) and date < DATE_TRUNC(current_date(), month)) OR
       (@period = "l6m" and date >= date_add(DATE_TRUNC(current_date(), month), interval -6 month) and date < DATE_TRUNC(current_date(), month)) OR
       (@period = "l1y" and date >= date_add(DATE_TRUNC(current_date(), year), interval -1 year) and date < DATE_TRUNC(current_date(), year)) OR
       (@period = "all")
      )      
      and ifnull(id,'') <> ''