Advertisement
Guest User

Untitled

a guest
Jan 29th, 2020
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.85 KB | None | 0 0
  1. select
  2.  
  3. CASE
  4. WHEN o.DeliveryID is NULL
  5. THEN UPPER(o.SpecialDeliveryID)
  6. WHEN o.DeliveryID = ''
  7. THEN UPPER(o.SpecialDeliveryID)
  8. ELSE CONCAT('MA', REPLACE(STR(o.DeliveryID, 8), SPACE(1), '0'))
  9. END as DOCUMENT,
  10.  
  11. CASE
  12. WHEN O.LocationID IN (29) --cand e traseu selecteaza soferul
  13. THEN oud.CodNaumSoftGestiuni
  14. ELSE ou.CodNaumSoftGestiuni
  15. END AS GESTIUNE_PRIMITOARE,
  16.  
  17. CASE
  18. WHEN O.LocationID IN (29)
  19. THEN oud.CodNaumSoft
  20. ELSE oud.CodNaumSoft
  21. END AS TRANSPORTATOR,
  22.  
  23. CASE
  24. WHEN v.CodNaumSoft is NULL
  25. THEN 'VN10AEX'
  26. WHEN v.CodNaumSoft = ''
  27. THEN 'VN10AEX'
  28. ELSE v.CodNaumSoft
  29. END as Vehicul,
  30.  
  31. p.CodNaumSoft as produs,
  32.  
  33. REPLACE(pl.Quantity,'.','.')
  34. as CANTITATE
  35.  
  36. from [Shipping].[ProductLists] pl
  37. inner join [Shipping].[Orders] o on pl.orderId = o.id
  38. inner join Shipping.Deliveries d on d.ID = o.DeliveryID
  39. INNER JOIN General.Users Ud ON Ud.ID = O.DriverID
  40. INNER JOIN General.Users Ul ON Ul.ID = O.LocationID
  41. inner join General.OldSystemProductCodes oc on oc.ProductId = pl.ProductID
  42. inner join General.OldSystemUserCodes ou on ou.UserID = o.LocationID
  43. inner join General.OldSystemUserCodes oud on oud.UserID = o.DriverID
  44. INNER JOIN GENERAL.PRODUCTS P ON P.ID = PL.PRODUCTID
  45. INNER JOIN Shipping.Vehicle v on d.VehicleID = v.ID
  46. where ((o.locationid in (29,56,57,58,59,60,61,62,63,64,85)) or (o.locationid = 80 and o.driverId=74)) AND O.COMPLETED = 1
  47. ------------------------------------------------------------------------------------
  48. --------------------------MODIFICA AICI---------------------------------------------
  49. AND CONVERT(varchar, o.DateCompleted,104) = '$Data' --ZZ.LL.AAAA ZIUA DORITA
  50. AND o.DepartmentID = $Sectie -- 2=Bru 3=Pat -- SECTIA DORITA
  51. ------------------------------------------------------------------------------------
  52. ORDER BY DOCUMENT ASC
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement