Advertisement
horozov86

LISTAGG - ORACLE

Aug 22nd, 2024
359
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. SELECT
  2.     A1.AUFTRAGSNUMMER AS "Order number", A1.AEXTERNAUFTRAGSNR AS "Client reference", SKUNDEN.NAME1 AS "Client name", SKUNDEN.MAINLAND AS "Country of the client",
  3.     SHIER.NR AS "Number of organisation", SHIER.BEZEICHNUNG AS "Name of organisation", LISTAGG(AT.TOURNUMMER, ', ') WITHIN GROUP (ORDER BY AT.TOURNUMMER) AS "Tour numbers",
  4.     TO_CHAR(MIN(ATASEND.VONLADEDATUM), 'DD-MM-YYYY') AS "First loading date"
  5. FROM AKOPF A1
  6. LEFT JOIN SHIERARCHIE SHIER ON SHIER.ID = A1.HIERARCHIE
  7. LEFT JOIN ASENDUNG ON A1.NR = ASENDUNG.AKOPFNR
  8. LEFT JOIN ATASEND ON ATASEND.ASENDUNGID = ASENDUNG.SENDUNGID
  9. LEFT JOIN ATOUR AT ON AT.NR = ATASEND.TOURNR
  10. LEFT JOIN SKUNDEN ON SKUNDEN.NR = A1.FRACHTAGNR
  11.  
  12. WHERE (AT.LKWKZ IS NOT NULL OR AT.ANHAENGERKZ IS NOT NULL) AND A1.AUFTRAGSNUMMER IN (908243, 220785)
  13.  
  14. GROUP BY A1.AUFTRAGSNUMMER, A1.AEXTERNAUFTRAGSNR, SKUNDEN.NAME1, SKUNDEN.MAINLAND, SHIER.NR, SHIER.BEZEICHNUNG
  15. ORDER BY MIN(ATASEND.VONLADEDATUM) ASC;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement