How can I sum the last 15 rows in my database table?
I have a sales table with the following columns:
- EmployeeID
- quantity
- date
Now I want to SUM
update the last 15 lines, so I'm currently doing:
SELECT TOP 15 SUM(amount) FROM Sales ORDER BY [Date] DESC
But I get 15 lines, obviously there is a way I can sum it up and no need to iterate over and SUM it on the client side?
0
a source to share