Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- select
- CASE
- WHEN o.DeliveryID is NULL
- THEN UPPER(o.SpecialDeliveryID)
- WHEN o.DeliveryID = ''
- THEN UPPER(o.SpecialDeliveryID)
- ELSE CONCAT('MA', REPLACE(STR(o.DeliveryID, 8), SPACE(1), '0'))
- END as DOCUMENT,
- CASE
- WHEN O.LocationID IN (29) --cand e traseu selecteaza soferul
- THEN oud.CodNaumSoftGestiuni
- ELSE ou.CodNaumSoftGestiuni
- END AS GESTIUNE_PRIMITOARE,
- CASE
- WHEN O.LocationID IN (29)
- THEN oud.CodNaumSoft
- ELSE oud.CodNaumSoft
- END AS TRANSPORTATOR,
- CASE
- WHEN v.CodNaumSoft is NULL
- THEN 'VN10AEX'
- WHEN v.CodNaumSoft = ''
- THEN 'VN10AEX'
- ELSE v.CodNaumSoft
- END as Vehicul,
- p.CodNaumSoft as produs,
- REPLACE(pl.Quantity,'.','.')
- as CANTITATE
- from [Shipping].[ProductLists] pl
- inner join [Shipping].[Orders] o on pl.orderId = o.id
- inner join Shipping.Deliveries d on d.ID = o.DeliveryID
- INNER JOIN General.Users Ud ON Ud.ID = O.DriverID
- INNER JOIN General.Users Ul ON Ul.ID = O.LocationID
- inner join General.OldSystemProductCodes oc on oc.ProductId = pl.ProductID
- inner join General.OldSystemUserCodes ou on ou.UserID = o.LocationID
- inner join General.OldSystemUserCodes oud on oud.UserID = o.DriverID
- INNER JOIN GENERAL.PRODUCTS P ON P.ID = PL.PRODUCTID
- INNER JOIN Shipping.Vehicle v on d.VehicleID = v.ID
- 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
- ------------------------------------------------------------------------------------
- --------------------------MODIFICA AICI---------------------------------------------
- AND CONVERT(varchar, o.DateCompleted,104) = '$Data' --ZZ.LL.AAAA ZIUA DORITA
- AND o.DepartmentID = $Sectie -- 2=Bru 3=Pat -- SECTIA DORITA
- ------------------------------------------------------------------------------------
- ORDER BY DOCUMENT ASC
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement