How to get data for past X weeks in redshift?

Don’t you want toWeek to be 1 greater than fromWeek? If so your where clauses should be:

...
and fromWeek <= date_part(w, current_date - interval '6 weeks') 
and toWeek >= date_part(w, current_date - interval '5 weeks')
...

I suspect you just don’t have data for values for toWeek that are high enough to pass your toWeek where clause.

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top