Imagine there are some data in Postgres table mytable
:
year | (iso) week |
---|---|
2021 | 50 |
2021 | 51 |
2021 | 52 |
2022 | 1 |
2022 | 2 |
… | … |
2022 | 52 |
2023 | 1 |
2023 | 2 |
… | … |
2023 | 24 (current week) |
I need to delete records that are between (2021, 51) and (2023, 1). It means that expected result should be:
year | (iso) week |
---|---|
2021 | 50 |
2023 | 2 |
… | … |
2023 | 24 (current week) |
What sql-query could filter this?
2
Answers
According to my experimental suggestion the below one will work
This can be done by combining the year and the week, converting them to integers, and then apply a standard where :
Demo here