I have two tables Application & Decision. Each Application can have many decisions. Each decision has a PK of Decision_ID, FK Application_ID and a DecisionDate
I’m trying to identify only those applications where the latest decision is prior to a specific date.
Example: Identify Applications were all decisions were made in 2011
If an application had 3 decisions, 2 in Nov/2011 and 1 in Feb/2012 I don’t want it returned.
If all 3 decisions were made in 2011 then I want it to returned the Application_ID
I know this code doesn't work but it's my starting point.
use Database select Application_ID from tbl_Decision where DecisionDate < '2012-01-01' group by Application_ID.
select Application_ID from tbl_Decision group by Application_ID having max(DecisionDate) < '2012-01-01'
========================================== Cursors are useful if you don't know sql. SSIS can be used in a similar way. Beer is not cold and it isn't fizzy.