Reputation: 51
I want to filter values from a table, between two weeks, like this:
select * from SalesWeekly where SalesWeek BETWEEN '50' and '02'
Problem is, i have no idea how to specify week 50 is from year 2019, and week 02 is from year 2020.
Upvotes: 2
Views: 48
Reputation: 222482
Assuming that you are storing the year in your table, say in table SalesYear
, you could concatenate it with the week number and do string comparisons:
select *
from SalesWeekly
where SalesYear || '-' || SalesWeek BETWEEN '2019-50' and '2020-02'
For this to work, SalesWeek
must be a 2-characters long string, left padded with 0
(so the 1st week should be '01'
, not '1'
).
Upvotes: 2