Advertisement
Pandaaaa906

Untitled

Aug 4th, 2022
1,326
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
T-SQL 0.53 KB | None | 0 0
  1. SELECT
  2. *
  3. FROM (
  4. SELECT
  5. po_m.cPOID,
  6. po_d.ID,
  7. po_d.cInvCode,
  8. po_d.cFree1,
  9. po_d.iQuantity po_qty,
  10. count(rd01_m.cCode) over(partition by iPOsID) count,
  11. rd01_d.iQuantity,
  12. sum(rd01_d.iQuantity) over(partition by iPOsID) total_qty,
  13. rd01_m.dVeriDate,
  14. rd01_m.cCode
  15.  
  16. FROM PO_Podetails po_d
  17.  
  18. LEFT JOIN PO_Pomain po_m
  19. ON po_d.POID = po_m.POID
  20.  
  21. LEFT JOIN rdrecords01 rd01_d
  22. ON rd01_d.iPOsID = po_d.ID
  23.  
  24. LEFT JOIN RdRecord01 rd01_m
  25. ON rd01_d.ID = rd01_m.ID
  26.  
  27. ) tmp
  28. WHERE po_qty < total_qty
  29.  
  30. ORDER BY cPOID, cInvCode, dVeriDate
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement