Advertisement
dragonbs

Hotels Revenue

Oct 15th, 2023
2,046
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
T-SQL 0.26 KB | None | 0 0
  1. SELECT H.Name AS HotelName,
  2.        SUM(R.Price * DATEDIFF(DAY, B.ArrivalDate, B.DepartureDate)) AS TotalRevenue
  3. FROM Bookings AS B
  4. INNER JOIN Hotels AS H ON B.HotelId = H.Id
  5. INNER JOIN Rooms AS R ON B.RoomId = R.Id
  6. GROUP BY H.Name
  7. ORDER BY TotalRevenue DESC;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement