Advertisement
Guest User

Untitled

a guest
Mar 27th, 2017
46
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.47 KB | None | 0 0
  1. SELECT
  2. first.ItemID, SUM(second.Quantity) as new_quantity
  3. FROM
  4. (SELECT
  5. first.ShopName, first.ItemID, second.Quantity
  6. FROM
  7. VillaLedger.VillaLedgerRaw as first
  8. JOIN
  9. VillaLedger.VillaLedgerRaw as second
  10. ON
  11. first.ItemID = second.ItemID AND first.ShopName = second.ShopName
  12. WHERE
  13. first.DocumentDate >= second.DocumentDate
  14. ORDER BY
  15. first.ItemID, first.ShopName, first.DocumentDate
  16. )
  17. GROUP BY
  18. first.ShopName, first.ItemID
  19. LIMIT 10
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement