我有date_ini和date_expired表的政策,并希望表示本date_ini和日期在2015年如何根据年份显示日期?
这里过期策略是信息:
|date_ini| |date_end|
2015-01-01 2015-06-03 Here is in the period 2015
2014-02-03 2015-09-08 Here is in the period 2015
2015-06-03 2016-09-08 Here is in the period 2015
2016-01-03 2016-09-08 Here is not in the period 2015
2015-06-03 2017-09-08 Here is in the period 2015
我想这demo:
select * from policies where YEAR(date_ini) >= 2015 AND YEAR(date_end) <= 2015
我应该有这样的答案:
|date_ini| |date_end|
2015-01-01 2015-06-03
2014-02-03 2015-09-08
2015-06-03 2016-09-08
2015-06-03 2017-09-08
请有人可以帮助我这个查询?
我不知道你为什么期待这个结果。您正在过滤** ** date_ini为2015或更高版本和date_end为2015或更低版本的行。换句话说,这两个字段在2015年必须有一个日期。唯一符合这些条件的行是第一个。 – Oldskool 2015-02-24 16:48:43