code_junkie

MS-Access design pattern for last value for a grouping

Nov 10th, 2011
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.43 KB | None | 0 0
  1. select *
  2. from table
  3. where account+time in (select account+max(time)
  4. from table
  5. group by account
  6. order by time)
  7.  
  8. select T1.account, T1.value
  9. from table T as T1
  10. where T1 = (select max(T2.time) from table T as T2 where T1.account = T2.Account)
  11.  
  12. SELECT TOP 1 * FROM TableName ORDER BY Time DESC
  13.  
  14. select account,last(value),max(time)
  15. from table
  16. group by account
Add Comment
Please, Sign In to add comment