This is strictly an SQL problem. You can't select any fields in a GROUP BY query unless they are either part of the GROUP BY list, or aggregated in some function or another (e.g. sum, count, etc).
In your case, you'd probably want to use SELECT Week, Status, sum(Amount).
Alternatively, you can load the full data (without a GROUP BY clause) and group it in QV's load statement, but you'll still have to aggregate Amount.
Thanks for your quick answer.
OK, I have managed to accomplish this in an original SQL database manager.
Is it correct that the problem is that I load and select different things in the script I provided? In "classic SQL" I just have to write...
Select Week, Status, sum(Amount) As Sales
GROUP BY Week, Status
... and I get the result set I want to get.
Can you please give me a code example of a possible solution?
Thank you very much!