从数据表中获取不属于过去3年的数据 [英] Get data from datatable which does not belong to last 3 years

查看:43
本文介绍了从数据表中获取不属于过去3年的数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

EndDate
2008-09-30 00:00:00.000
2009-09-30 00:00:00.000
2010-09-30 00:00:00.000
2011-09-30 00:00:00.000
2012-09-30 00:00:00.000
2011-09-30 00:00:00.000
2011-09-30 00:00:00.000
2013-09-30 00:00:00.000





我有桌子abc wheer Enddate是专栏..我需要获得不属于过去3年的3年记录的ID。



即我想选择的数据2008年和2009年ID离开过去3年(2013,2012,2011)的记录



根据情况而变化。



提前感谢您的帮助。



I have table abc wheer Enddate is column.. I need to get the id of 3 year records which does not belong to last 3 years.

i.e I want to pick the data of 2008 and 2009 ID leaving last 3 years (2013,2012,2011)records

It changes according to the condition.

Thanks in advance for any help.

推荐答案

从tblname中选择*,其中CRO ='00000645'

select * from tblname where CRO = '00000645'
Acc_ID		EndDate	                  CRO	                     EntryDate
3927175		2009-12-31 00:00:00.000	 00000645	2010-11-16 00:00:00.000
5859809		2008-12-31 00:00:00.000	 00000645	2009-10-09 00:00:00.000
6000968		2010-12-31 00:00:00.000	 00000645	2011-09-23 00:00:00.000
8963188		2011-12-31 00:00:00.000	 00000645	2012-12-04 00:00:00.000
11309851        2012-12-31 00:00:00.000	 00000645	2013-10-23 00:00:00.000
14154225        2013-12-31 00:00:00.000	 00000645	2014-11-13 00:00:00.000
14301133	2013-12-31 00:00:00.000	 00000645	2014-12-03 

i want to get the ID which does not belong to last 3 years i.e(2013, 2012, 2011)
If co changes the value also change. 00000645	 is CRO
I am sorry, the table didnt come in proper manner.


这篇关于从数据表中获取不属于过去3年的数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆