However, first problem - you are using

`Partition By`

for the quarter, but you also need to partition by the `CustomerID`

SQL

Sum(TotalDue) Over (Partition ByAlso, you have usedCustomerID,dateadd(qq, 3, OrderDate)) as TotalSpent

`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. SQL

order by Sum(TotalDue) Over (Partition By CustomerID, dateadd(qq, 3, OrderDate)) descOR

SQL

order by 2 descwill 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

Besides, to also get the total amount spent, just add that as column query (such as SUM(amount_spent). But remember, for aggregate functions you also need to use grouping in SQL.