SQL GROUP BY week (Monday 07:00:00 to Monday 06:59:59)
12,367
SELECT to_char(wid_date - 7/24,'IYYY'), to_char(wid_date - 7/24,'IW'), tonnes
FROM production
WHERE to_char(wid_date - 7/24,'IYYY') = '2009'
GROUP BY to_char(wid_date - 7/24,'IYYY'), to_char(wid_date - 7/24,'IW')
Author by
Admin
Updated on June 05, 2022Comments
-
Admin almost 2 years
I've created a query that groups production data on ISO week by using this query
SELECT to_char(wid_date,'IYYY'), to_char(wid_date,'IW'), tonnes FROM production WHERE to_char(wid_date,'IYYY') = '2009' GROUP BY to_char(wid_date,'IYYY'), to_char(wid_date,'IW')
The problem is that our "production weeks" don't follow the ISO standard. They run from Monday morning at 07:00:00 to Monday morning at 06:59:59.
Any suggestions on how I can get it to report using our production weeks?
Thanks kindly,
Tommy