Click here to Skip to main content
15,897,518 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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


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.
Posted
Comments
Mehdi Gholam 22-May-15 3:07am    
... and what is your question, where are you stuck?

1 solution

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.
 
Share this answer
 
v3

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900