datazang
datazang

Reputation: 1169

How to filter data by month and year in Athena?

I want to filter the daily data by month and year. For instance, it will show the daily sales on a daily basis in only January 2020 and January 2021.

SELECT date, sum(sales) as sales
FROM X
WHERE date = ('2020-01') and date = ('2021-01')
GROUP BY 1

How can I do this?

Upvotes: 0

Views: 2268

Answers (1)

Oguzhan Aygun
Oguzhan Aygun

Reputation: 1664

Date format seems to be problem. Can you try something like this?

SELECT date, sum(sales) as sales
FROM X
WHERE time BETWEEN TIMESTAMP '2020-01-01' AND TIMESTAMP '2021-01-01'
GROUP BY 1

Upvotes: 1

Related Questions