我正在尝试从Database获取最新日期。但是在'Reservation.EntryDate'
Select Rooms.RoomTitle,Rooms.IsReserved,Reservation.CheckInTime,Reservation.CheckOutTime
From Reservation,Rooms
INNER JOIN
(SELECT Reservation.RoomID, MAX(Reservation.EntryDate) AS MaxDateTime
FROM Reservation
GROUP BY Reservation.RoomID) groupedtt
ON Rooms.RoomID = groupedtt.RoomID
AND Reservation.EntryDate = groupedtt.MaxDateTime
我做错了什么?
答案 0 :(得分:1)
不要混合隐式和显式连接语法
Select ro.RoomTitle,
ro.IsReserved,
res.CheckInTime,
res.CheckOutTime
From Reservation res
join Rooms ro ON ro.RoomID = res.RoomID
join
(
SELECT RoomID, MAX(EntryDate) AS MaxDateTime
FROM Reservation
GROUP BY RoomID
) groupedtt ON ro.RoomID = groupedtt.RoomID
AND res.EntryDate = groupedtt.MaxDateTime