create table #temp
(
    id int identity(1,1),
    name varchar(20),
    startYear int,
    startMonth int
)

insert into #temp
select 'z','2010','12' union all
select 'e','2011','11' union all
select 'a','2011','2' union all
select 'b','2011','5' union all
select 'c','2011','10' union all
select 'd','2011','7'

--查询早于等于指定日期的数据
declare @condition varchar(6)
set @condition='201110'

select * from #temp A
where
 (case when LEN(A.startMonth)=1 and A.startMonth!=0 then cast((CAST(startYear as varchar(4))+'0'+cast(A.startMonth as varchar(1))) as date)
       when LEN(A.startMonth)=2 then cast(CAST(startYear as varchar(4))+cast(A.startMonth as varchar(2)) as date) end) <=cast(@condition as date)

最新文章

  1. Spring Boot 添加Shiro支持
  2. 走进云背后:微软Azure web 项目通过web service部署web site
  3. Mac SVN 命令行
  4. 以纯面向对象的JS编写最基本的数据字典案例
  5. ASP------如何使界面布局具有一致外观
  6. 乐够GO应用源码完整版
  7. SQL Server 非聚集索引的覆盖,连接,交叉和过滤 &lt;第二篇&gt;
  8. 去除 waring Method &#39;CreateNew&#39; hides virtual method of base type &#39;TCustomForm&#39;
  9. 3.8 spring - AbstractBeanDefinition 介绍
  10. 黑马程序猿 IO流 ByteArrayInputStream与ByteArrayOutputStream
  11. android 菜单的总结
  12. Python之MYsql、数据库
  13. 实用技巧:如何通过IP地址进行精准定位
  14. OAuth2.0学习(1-9)新浪开放平台微博认证-web应用授权(授权码方式)
  15. (十分钟视频教程)nodejs基础实战教程3:react服务端渲染入门篇
  16. const_cast的用法与测试
  17. Code Signal_练习题_stringsRearrangement
  18. 使用OpenOffice.org将各类文档转为PDF
  19. bzoj 2784 [JLOI2012]时间流逝——树上高斯消元
  20. [2018HN省队集训D6T2] girls

热门文章

  1. perf-perf stat用户层代码分析
  2. [forward]警惕UNIX下的LD_PRELOAD环境变量
  3. STL中队列queue的用法
  4. 洛谷——P2814 家谱
  5. 【郑轻邀请赛 B】base64解密
  6. [bzoj1926][Sdoi2010]粟粟的书架_二分_主席树
  7. 多校第六场 1003 hdu 5355 Cake(贪心)
  8. Android 的Recovery机制【转】
  9. Mac safari&#160;下iframe的hash取不到BUG
  10. Spring:延迟初始化