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 |
Durbslaw
Starting Member
43 Posts |
Posted - 2011-03-28 : 04:28:47
|
Hi All, Thank you for reading and the suggestions, I have view I am trying to alter, it is currently quering a field in a table that is updated once every six months, I would like to the query reference the last record in the updated column, here is a code snippet( select t.AccountNum as VoteNo, t.FinYear, sum(t.amount) As CurrentBudget from ( select v.AccountNum, v.startdate, v.ModelNum, FinYear = case when datepart(month, startdate) >= 7 then convert(varchar(4), datepart(year, startdate)) + '/' + convert(varchar(4), datepart(year, startdate) + 1) else convert(varchar(4), datepart(year, startdate) - 1) + '/' + convert(varchar(4), datepart(year, startdate)) end, v.amount from ledgerbudget v ) t where modelnum = 'BUD10/111' group by t.FinYear, t.accountnumideally the line wheremodelnum ='whatever' should readwheremodelnum = LAST(ledgerbudget.modelnum)Thanks again... |
|
Durbslaw
Starting Member
43 Posts |
Posted - 2011-03-29 : 01:01:02
|
http://social.msdn.microsoft.com/Forums/en/transactsql/thread/0a96af01-da0f-48d7-9ed9-c61628962306 |
 |
|
|
|
|
|
|