oracle SQL GROUP BY 周(周一 07:00:00 至周一 06:59:59)

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1067315/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-18 18:29:57  来源:igfitidea点击:

SQL GROUP BY week (Monday 07:00:00 to Monday 06:59:59)

sqloracledatetime

提问by Jeffrey Kemp

I've created a query that groups production data on ISO week by using this query

我创建了一个查询,通过使用此查询对 ISO 周的生产数据进行分组

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.

问题是我们的“生产周”没有遵循 ISO 标准。它们从星期一早上 07:00:00 运行到星期一早上 06:59:59。

Any suggestions on how I can get it to report using our production weeks?

关于如何使用我们的生产周进行报告的任何建议?

Thanks kindly,

好心谢谢

Tommy

汤米

回答by Jeffrey Kemp

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')