alexbancheva

Task10_GDPR_Violation_Exam21June2020

Feb 5th, 2021
1,193
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. SELECT t.Id, a.FirstName + ' ' + ISNULL(a.MiddleName + ' ', '') + a.LastName AS FullName, c.[Name] AS Hometown,
  2.     ca.[Name] AS [To],
  3.     CASE
  4.         WHEN t.CancelDate IS NULL THEN CONCAT(DATEDIFF(DAY, t.ArrivalDate,t.ReturnDate),' ', 'days')
  5.         ELSE 'Canceled'
  6.         END AS Duration
  7.         FROM AccountsTrips AS [at]
  8.             JOIN Accounts AS a ON a.Id = [at].AccountId
  9.             JOIN Trips AS t ON t.Id = [at].TripId
  10.             JOIN Cities AS c ON a.CityId = c.Id
  11.             JOIN Rooms AS r ON t.RoomId = r.Id
  12.             JOIN Hotels AS h ON r.HotelId = h.Id
  13.             JOIN Cities AS ca ON h.CityId = ca.Id
  14.             ORDER BY FullName ASC,
  15.                 t.Id ASC
RAW Paste Data