Custom sql athena

How do I automatically set through custom SQL in Athena to take the last 3 months? How do I set up the WHERE clause?


Hi @andreab
can I assume you have a date column?

Something like where DATEDIFF(month, now(), datecolumn) <=3


1 Like

Hi @ErikG

Like this?

SELECT CONCAT(hostname,pagepath) as link_sito, date_parse(date, ‘%Y%m%d’) as data_ga4, cast(eventcount AS INTEGER) as page_views

FROM ga4_db.esg360_ga4

WHERE eventname=‘page_view’ AND date_diff(‘month’, now(), date_parse(date, ‘%Y%m%d’)) <=3