我正在努力弄清楚如何将列从列转换为以下查询:
SELECT RoomCalendar.RoomCalendarId, RateRoomCombination.RateTypeId, RateRoomCombination.RoomTypeId, RateType.RateTypeName+' '+RoomTypes.RoomName AS Rooms, Hotels.HotelId, Hotels.HotelName, RoomCalendar.Availability, RoomCalendar.BookedNights, RoomCalendar.FinalAvailability, RoomCalendar.Rate, RoomCalendar.PricingDate
FROM Hotels INNER JOIN (RoomTypes INNER JOIN (RateType INNER JOIN (RateRoomCombination INNER JOIN RoomCalendar ON RateRoomCombination.RateRoomCombinationId = RoomCalendar.RateRoomCombinationId) ON RateType.RateTypeId = RateRoomCombination.RateTypeId) ON RoomTypes.RoomTypeId = RateRoomCombination.RoomTypeId) ON (Hotels.HotelId = RoomTypes.HotelId) AND (Hotels.HotelId = RateType.HotelId) WHERE Hotels.HotelId=1 AND RoomCalendar.PricingDate BETWEEN #01/01/2016# AND #31/01/2016# AND RoomCalendar.RateRoomCombinationId=17
此查询的结果如下:
PricingDate Rooms Availability BookedNights FinalAvailability Rate
01/01/2016 Double 5 1 4 90
02/01/2016 Double 5 2 3 85
03/01/2016 Double 5 5 0 93
04/01/2016 Double 5 4 1 91
05/01/2016 Double 5 2 3 96
etc. etc. etc. etc. etc. etc.
我想得到以下结果:
01/01/2016 02/01/2016 03/01/2016 04/01/2016 5/01/2016
Availability 5 5 5 5 5
BookedNights 1 2 5 4 2
FinalAvailability 4 3 5 1 3
你有什么建议吗?
谢谢