Advertisement
horozov86

Task 2 - SQL

Aug 20th, 2024 (edited)
338
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. SELECT
  2.     A1.AUFTRAGSNUMMER AS "Order number",
  3.     A1.AEXTERNAUFTRAGSNR AS "Client reference",
  4.     SKUNDEN.NAME1 AS "Client name",
  5.     SKUNDEN.MAINLAND AS "Country of the client",
  6.     SHIER.NR AS "Number of organisation",
  7.     SHIER.BEZEICHNUNG AS "Name of organisation",
  8.     TOURNUMMER AS "Number of Tour",
  9.     CASE
  10.         WHEN AT.LKWKZ IS NOT NULL THEN AT.LKWKZ
  11.         ELSE AT.ANHAENGERKZ
  12.     END AS "License plate",
  13.     TO_CHAR(ATASEND.VONLADEDATUM, 'DD-MM-YYYY') AS "First loading date"
  14. FROM
  15.     AKOPF A1
  16. LEFT JOIN
  17.     SHIERARCHIE SHIER ON SHIER.ID = A1.HIERARCHIE
  18. LEFT JOIN
  19.     ASENDUNG ON A1.NR = ASENDUNG.AKOPFNR
  20. LEFT JOIN
  21.     ATASEND ON ATASEND.ASENDUNGID = ASENDUNG.SENDUNGID
  22. LEFT JOIN
  23.     ATOUR AT ON AT.NR = ATASEND.TOURNR
  24. LEFT JOIN
  25.     SKUNDEN ON SKUNDEN.NR = A1.FRACHTAGNR
  26. WHERE
  27.     (AT.LKWKZ IS NOT NULL OR AT.ANHAENGERKZ IS NOT NULL)
  28. --    AND ATASEND.VONLADEDATUM IS NOT NULL;
  29.     AND A1.AUFTRAGSNUMMER = 908243
  30. ORDER BY
  31.     ATASEND.VONLADEDATUM ASC
  32. FETCH FIRST ROW ONLY;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement