当我运行下面的查询(第一个代码)时,我会根据数据库中的当前到达日期得到 137 万个随机出发日期,这是个好消息。但是,当我尝试使用第二个代码查询更新数据库时,我收到一条错误消息(见下文),我不知道为什么。你能帮我吗?
Msg 116, Level 16, State 1, Line 5 当子查询没有用 EXISTS 引入时,只能在选择列表中指定一个表达式。
第一个代码
SELECT ArrivalDate, DATEADD(day, 1 + RAND(checksum(NEWID()))
* LengthOfStay.LengthofStay, ArrivalDate) AS DepartureDate
FROM Bookings, LengthOfStay
ORDER BY ArrivalDate
第二代码
USE Occupancy
Update Bookings
Set DepartureDate = (SELECT ArrivalDate, DATEADD(day, 1 + RAND(checksum(NEWID()))*1.5
* LengthOfStay.LengthofStay, ArrivalDate))
FROM LengthOfStay, Bookings