Advertisement
horozov86

Task 17 - SQL

Oct 14th, 2024
191
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
SQL 1.09 KB | None | 0 0
  1. SELECT
  2.     ATOUR.TOURNUMMER AS "Tour number",
  3.     MAX(ATASEND.VON_LAND || '/' || ATASEND.VON_ORT1 || '/' || ATASEND.VON_PLZ) KEEP (DENSE_RANK FIRST ORDER BY ATASEND.VONLADEDATUM) AS "First Full Address of Loading",
  4.     MAX(ATASEND.NACH_LAND || '/' || ATASEND.NACH_ORT1 || '/' || ATASEND.NACH_PLZ) KEEP (DENSE_RANK LAST ORDER BY ATASEND.BISLIEFERDATUM) AS "Last Full Address of Unloading",
  5.     MIN(ATASEND.VONLADEDATUM) AS "First loading date",
  6.     MAX(ATASEND.BISLIEFERDATUM) AS "Last unloading date",
  7.     NAME1 AS "Carrier Name",
  8.     MAINLAND AS "Country of the carrier",
  9.     SUM(BETRAG) AS "Tour Amount",
  10.     CFDATETIME7 AS "Shipeo Pair Date"
  11.  
  12. FROM
  13.     ATOUR
  14. JOIN
  15.     ATASEND ON ATOUR.NR = ATASEND.TOURNR
  16. JOIN
  17.     SKUNDEN ON SKUNDEN.NR = ATOUR.UNTERNEHMER
  18. JOIN
  19.     ASDGABRECHNUNG ON ATASEND.NR = ASDGABRECHNUNG.ATAID
  20. JOIN
  21.     atourcustomfieldv ON atourcustomfieldv.id = atour.nr
  22.  
  23. WHERE
  24.     ATOUR.TOURNUMMER = 437883
  25.  
  26. GROUP BY
  27.     ATOUR.TOURNUMMER,
  28.     SKUNDEN.NAME1,
  29.     SKUNDEN.MAINLAND,
  30.     CFDATETIME7
  31. HAVING
  32.     MIN(ATASEND.VONLADEDATUM) >= TO_DATE('01-03-2024', 'DD-MM-YYYY');
  33.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement