Advertisement
horozov86

Task 4 - SQL

Aug 23rd, 2024 (edited)
341
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. SELECT DISTINCT
  2.     SKUNDEN.NAME1 AS "Name of carrier",
  3.     ATOUR.TOURNUMMER AS "Tour number",
  4.     ATOUR.PREISVORGABEBETRAGGS AS "Price for transport",
  5.     SWAEHRUNG.ISOWAEHRUNGSCODE AS "Currency",
  6.     MIN(ATASEND.VONLADEDATUM) AS "Loading date",
  7.     MAX(ATASEND.VONLIEFERDATUM) AS "Unloading date",
  8.     SHIERARCHIE.EXTERNEREFERENZ1 AS "Team",
  9.     CONCAT(CONCAT(ATOUR.LKWKZ, '/') ,ATOUR.ANHAENGERKZ) AS "Truck and Trailer number"
  10.  
  11. FROM
  12.     ATOUR
  13. LEFT JOIN
  14.     SKUNDEN ON SKUNDEN.NR = ATOUR.UNTERNEHMER
  15. LEFT JOIN
  16.     ATASEND ON atour.NR = atasend.TOURNR
  17. LEFT JOIN
  18.     SHIERARCHIE ON SHIERARCHIE.ID = ATOUR.HIERARCHIE
  19. LEFT JOIN
  20.     swaehrung ON SWAEHRUNG.ID = ATOUR.PREISVORGABEWAEHRUNGIDGS
  21.    
  22. GROUP BY
  23.     SKUNDEN.NAME1,
  24.     ATOUR.TOURNUMMER,
  25.     ATOUR.PREISVORGABEBETRAGGS,
  26.     SWAEHRUNG.ISOWAEHRUNGSCODE,
  27.     SHIERARCHIE.EXTERNEREFERENZ1,
  28.     ATOUR.LKWKZ,
  29.     ATOUR.ANHAENGERKZ
  30.    
  31. ORDER BY
  32.     ATOUR.TOURNUMMER DESC,
  33.     MIN(ATASEND.VONLADEDATUM) ASC,
  34.     MAX(ATASEND.VONLIEFERDATUM);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement