I got total 160 Quantity in the Stock.
How to get first 100 quantity total amount and last 60 quantity total amount?
The table is sort by Date and Stock ID.
For first 100
select
Product ID, sum(Quantity) as Quantity, sum(Amount) asTotalAmountfrom (SELECT * from tblstock order bytblStock.Stock IDASC limit 100) t1 GROUP BYDate,Product ID
For last 60
select
Product ID, sum(Quantity) as Quantity, sum(Amount) asTotal Amountfrom (SELECT * from tblstock order bytblStock.Stock IDDESC limit 60) t1 GROUP BYDate,Product ID