I am creating a simple query with a not so simple twist, at least it's not simple to me. First, the query:
select distinct b.Bank_Mnemonic as [Bank],bd.Demo_Name as [Demography],ei.BEFI_Description[Economic Indicator],bsd.BSD_Year as [Year],bsd.BSD_Data_Value as [Value] from dbo.tblBank_Source_Data as bsd inner join dbo.tblBankDemographics as bd on bsd.Demo_ID=bd.Demo_ID inner join dbo.tblBanks as b on bsd.Bank_ID=b.Bank_ID inner join dbo.tblEconomicFinancialIndicators as ei on bsd.BEFI_ID=ei.BEFI_ID where (bd.Demo_Name='Canada' and bsd.BSD_Quarter=0 and b.Bank_Mnemonic='BMO' and bsd.BSD_Date_Modified ='2013-07-23') order by ei.BEFI_Description
The spot where I need help with is the bsd.BSD_Date_Modified = '2013-07-23' in that what I really need is the most recent date modified value without having to hard code it as a date like I did. Is this even possible? I'm going to play around with assigning variables but even at that I am not very sure how to do that. It is important to note that the most recent date modified is most important as there can be a 2013-07-11 that would be useless if the 07-23 exists. Am I being clear enough? I really hope so.