Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
Redser
Starting Member
9 Posts |
Posted - 2012-06-19 : 06:00:46
|
| 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_IDI know this code doesn't work but it's my starting point.use Databaseselect Application_ID from tbl_Decisionwhere DecisionDate < '2012-01-01'group by Application_ID. |
|
|
nigelrivett
Master Smack Fu Yak Hacker
3385 Posts |
Posted - 2012-06-19 : 06:27:56
|
| select Application_IDfrom tbl_Decisiongroup by Application_IDhaving 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. |
 |
|
|
Redser
Starting Member
9 Posts |
Posted - 2012-06-19 : 08:17:46
|
| Thanks for you help nigelrivett. Much appreciated |
 |
|
|
|
|
|