Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- SELECT
- first.ItemID, SUM(second.Quantity) as new_quantity
- FROM
- (SELECT
- first.ShopName, first.ItemID, second.Quantity
- FROM
- VillaLedger.VillaLedgerRaw as first
- JOIN
- VillaLedger.VillaLedgerRaw as second
- ON
- first.ItemID = second.ItemID AND first.ShopName = second.ShopName
- WHERE
- first.DocumentDate >= second.DocumentDate
- ORDER BY
- first.ItemID, first.ShopName, first.DocumentDate
- )
- GROUP BY
- first.ShopName, first.ItemID
- LIMIT 10
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement