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.
tblStock
+----------+------------+----------+----------+------------+
+ Stock ID + Product ID + Quantity + Amount + Date +
+----------+------------+----------+----------+------------+
+ 1 + 1001 + 50 + 10.00 + 2014-11-10 +
+----------+------------+----------+----------+------------+
+ 2 + 1001 + 70 + 11.00 + 2014-11-11 +
+----------+------------+----------+----------+------------+
+ 3 + 1001 + 30 + 9.90 + 2014-11-12 +
+----------+------------+----------+----------+------------+
+ 4 + 1001 + 10 + 10.20 + 2014-11-13 +
+----------+------------+----------+----------+------------+
I need two result of below. Thanks
Result A (first 100 quantity)
+------------+----------+--------------+
+ Product ID + Quantity + Total Amount +
+------------+----------+--------------+
+ 1001 + 100 + 1050.00 +
+------------+----------+--------------+
Result B (last 60 quantity)
+------------+----------+--------------+
+ Product ID + Quantity + Total Amount +
+------------+----------+--------------+
+ 1001 + 60 + 619.00 +
+------------+----------+--------------+
For first 100
For last 60