It might have been best if you had just typed in what your homework assignment said because you didn't explain it very well.
However, first problem - you are using
Partition By
for the quarter, but you also need to partition by the
CustomerID
Sum(TotalDue) Over (Partition By CustomerID, dateadd(qq, 3, OrderDate)) as TotalSpent
Also, you have used
top 1
but you have not ordered the results so the single row returned is quite random. You need to include an
order by
clause e.g.
order by Sum(TotalDue) Over (Partition By CustomerID, dateadd(qq, 3, OrderDate)) desc
OR
order by 2 desc
will also work - read this as "order by the 2nd item in the SELECT list, highest value first"
I'm not sure if the overall total for that customer is supposed to be in the same query or not - if it is then include another
Sum
using
Partition By
but this time you don't need to partition by the quarter.
That should be enough to get you moving on this again