【发布时间】:2021-07-23 00:27:14
【问题描述】:
我的数据中有两列,分别称为年和月。我只想提取日期大于 > 201802 且小于 202103 的数据。
select
*
from table
where year+month between 201802 and 202103..
是我想要的。我的两列都是整数。我该怎么做?
【问题讨论】:
我的数据中有两列,分别称为年和月。我只想提取日期大于 > 201802 且小于 202103 的数据。
select
*
from table
where year+month between 201802 and 202103..
是我想要的。我的两列都是整数。我该怎么做?
【问题讨论】:
你可以使用算术:
where year * 100 + month between 201802 and 202103
或者,您可以使用元组(但不能使用 between):
where (year, month) >= (2018, 02) and
(year, month) <= (2021, 03)
【讨论】: