Home » How to select only one year data from this week in Redshift

How to select only one year data from this week in Redshift

I have a table like following

year  month isoweek day
・
・
2020  12     49  2021/12/5
・
・ 
2020  12    50  2021/12/7
・
・
2021  12     51  2021/12/20 
2021  12     51  2021/12/21

I’d like to select only one year in isoweek in this example, today is 2021/12/20 and its isoweek in this table is 51 I’d like to get 2020 isoweek 52 to 2021 isoweek 51. Are there any way to achieve this?

year  month isoweek day
2020  12    52  2021/12/21 
・
・
2021  12     51  2021/12/20 
2021  12     51  2021/12/21

I tried following query, but it still cant extract one year range.

select *
from table
where day <= current_date

If someone has opinion,please let me know Thanks

Alvin Craig

Back to top