我有以下列:year_month(201403,201404,... 201602,201603),ID_account(123,456,789),DPD(某些数字)。对于ID_account,我需要在过去6个月内找到max_DPD作为max_DPD。像这样(SSMS2008):
year_month || ID_account || DPD || max_DPD
----------------------------------------------------
201403 || 123 || 30 || 30
201404 || 123 || 0 || 30
201405 || 123 || 45 || 45
201406 || 123 || 1 || 45
201403 || 456 || 0 || 0
201404 || 456 || 12 || 12
201405 || 456 || 20 || 20
201406 || 456 || 0 || 20
201403 || 789 || 0 || 0