I have the following simplified table structure in a SQL 2000 Databse:
ID AppName Key Value EffectiveDate
-- ------- ----- ------- -------------
1 App1 One Past 1/1/1900
2 App1 One Present 1/1/2010
3 App1 One Future 1/1/9999
4 App1 Two Past 1/1/1900
5 App1 Two Present 1/1/2010
6 App1 Two Future 1/1/9999
7 App2 One Present 1/1/2010
8 App2 Two Present 1/1/2010
I need to be able to ask the question:
Given a specific AppName, show me all ONLY THE MOST RECENT Key/Value pairs whose EffectiveDate <= GetDate()
So if I called my mystery query with AppName = 'App1' then my results would be:
ID AppName Key Value EffectiveDate
-- ------- ----- ------- -------------
2 App1 One Present 1/1/2010
5 App1 Two Present 1/1/2010
EDIT:
Value can be anything. (‘Past’,’Present’,’Future’) were merely used to make the example more clear. They could very well have been (45,’Bob’,’%$#%@#$’).
I think you need to use something like this: