在过去4年的一月到三月之间获取数据
我最近四年的数据是2018,2019,2020,2021。 在此过程中,我需要一月至3月的数据,2018年,2019,2020,2021。
我可以写四次日期。 但是我不希望查询看起来很大。因此,在一个查询中如何获取数据
I've data of last 4 years that is 2018,2019,2020,2021.
Out of this I need data from JANUARY TO MARCH in all 2018,2019,2020,2021.
I can write date between four times.
But I don't want the query to look very big. So in a single query how to get that data
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果有一个
date
datatype列(应该为;我们称其为datum
),则可以例如,如果将日期存储为字符串(中
varchar2 列),然后首先使用
to_date
函数使用适当的格式模型将其转换为有效date
datatype值。例如,如果将值存储为20220715(这是
yyyymmdd
),则其余查询是相同的:
当心! Oracle不将字符串作为日期处理!该列中可能有无效的值,例如“ 20AC#713”;将
to_date
应用于它会引起错误(因为这显然不是日期)。或者,如果有“ 20220230”(2月30日),您将再次出现错误。始终将日期存储到
date
数据类型列!If there's a
DATE
datatype column (should be; let's call itdatum
), then you could e.g.If you stored dates as strings (into a
VARCHAR2
column), then first convert it to a validdate
datatype value using theTO_DATE
function with appropriate format model.For example, if values are stored as 20220715 (which is
yyyymmdd
),The rest of query is just the same:
Beware! Oracle doesn't handle strings as dates! There might be invalid values in that column, e.g. "20ac#713"; applying
to_date
to it will raise error (as that's obviously not a date). Or, if there were "20220230" (30th of February), you'll get error again.Always store dates into
date
datatype columns!