在这个 SQL Server 查询中,我想为每个预订最多返回 1 个 lostReason。但是,子查询似乎为每个预订返回了 lostBusiness 表中的第一条记录。让我知道是否需要澄清。
SELECT
bookings.bookingNumber, lost.lostReason
FROM
bookings
LEFT OUTER JOIN(SELECT TOP (1)
bookingNumber,
lostReason
FROM
lostBusiness) AS lost ON bookings.bookingNumber = lost.bookingNumber