daily pastebin goal
38%
SHARE
TWEET

Untitled

a guest Nov 14th, 2017 52 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. SELECT LU.DELIVERY_ID "Nr dostawy",LU.DATE_Z "Data zak. real",LU.LOADUNITS "Ilość nośników",K.KARTONY "Ilość kartonów",LU.FIRM_NR FROM
  2.  
  3. (SELECT PCG.DELIVERY_ID,SUM(PCG.KARTON) AS KARTONY FROM
  4.  
  5. (SELECT DI.DELIVERY_ID,DI.PACKAGE_ID,SUM(DI.BU_QUANTITY) AS SZTUKA,CEIL(SUM(DI.BU_QUANTITY)/PL.BU_QUANTITY) AS KARTON ,PL.BU_QUANTITY
  6.  
  7. FROM DELIVERY_ITEMS DI LEFT JOIN QCM_PACKAGE_LEVELS PL ON DI.PACKAGE_ID=PL.PACKAGE_ID
  8.  
  9. WHERE PL.LEVEL_NR='1' AND DI.STATUS='FI'
  10.  
  11. GROUP BY DI.DELIVERY_ID,PL.LEVEL_NR,DI.PACKAGE_ID,PL.BU_QUANTITY)PCG
  12.  
  13. GROUP BY PCG.DELIVERY_ID)K
  14.  
  15. LEFT JOIN
  16.  
  17. (SELECT TO_CHAR(D.LM_DATE,'YYYY-MM-DD') AS DATE_Z,DI.DELIVERY_ID,COUNT(DI.LOADUNIT_ID) AS LOADUNITS,F.FIRM_NR
  18.  
  19. FROM (SELECT DISTINCT DELIVERY_ID,LOADUNIT_ID FROM DELIVERY_ITEMS) DI LEFT JOIN DELIVERIES D ON DI.DELIVERY_ID=D.DELIVERY_ID LEFT JOIN QCM_FIRMS F ON D.FIRM_ID=F.FIRM_ID
  20.  
  21. WHERE D.STATUS='FI' GROUP BY TO_CHAR(D.LM_DATE,'YYYY-MM-DD'),DI.DELIVERY_ID,D.STATUS,F.FIRM_NR) LU
  22.  
  23. ON K.DELIVERY_ID=LU.DELIVERY_ID
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top