Advertisement
Guest User

Untitled

a guest
Jan 26th, 2020
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.18 KB | None | 0 0
  1. (case when a.qty != pas.qty1 then a.qty - pas.qty1
  2. else a.qty end ) as qty
  3.  
  4.  
  5.  
  6. left join (
  7. select *, sum(qty) as qty1 from
  8. (
  9. select *, 1 as uploadflag from promats_allocation_status
  10. group by allocationid, promatsallocreasonid,isReturned
  11. union all
  12. select * from promats_allocation_status_save
  13. group by allocationid, promatsallocreasonid,isReturned
  14. )
  15. where PromatsAllocReasonID = 0
  16. group by allocationid, isReturned
  17. ) pas
  18. on a.allocationid = pas.allocationid
  19.  
  20. select pas.AllocationID from
  21. (
  22. select *, sum(qty) as qty1 from
  23. (
  24. select *, 1 as uploadflag from promats_allocation_status
  25. group by allocationid, promatsallocreasonid,isReturned
  26. union all
  27. select * from promats_allocation_status_save
  28. group by allocationid, promatsallocreasonid,isReturned
  29. )
  30. group by allocationid, isReturned
  31. ) pas
  32. inner join allocation a
  33. on a.AllocationID = pas.AllocationID
  34. where pas.qty1 = a.qty
  35. and pas.PromatsAllocReasonID = 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement