SELECT YEAR(aum.AUM_Timeperiod) as Year,
DATEPART(q, aum.AUM_TimePeriod) AS Quarter,
SUM(cast(aum.AUM_AssetValue AS money)) as total_AssetValue
FROM AssetUnderManagement as aum,
LineOfBusiness
where aum.LOB_ID = LineOfBusiness.LOB_ID
and LineOfBusiness.LOB_Name = 'Asset Management'
GROUP BY YEAR(aum.AUM_Timeperiod), DATEPART(q, aum.AUM_TimePeriod);
The above query returns the value per quarter.
My question is how to change it if I want the Total_AssetValue
of the last month in that quarter to be assigned to that quarter.
For eaxmple Quater 3 total_AssetValue is sum(100+200+300). but i want the quater 3 value to be 300 which is the last month value in that quater