日期:2014-05-17  浏览次数:20438 次

SQL 查询语句脚本时间跨度
表结构

year      month 

2009    1

2009    2

2009    3

2009    4

......

2012  12

现在想查出 2009-5  到2012-6的数据,求脚本

?

------解决方案--------------------

select [year], [month]
 from [表名]
 where cast(rtrim([year])+'-'+rtrim([month])+'-01' as date)
 between '2009-05-01' and '2012-06-01'