select *
from orders o
WHERE EXISTS
(
select 1
from orders o2
where o2.EmployeeID = o.EmployeeID
AND YEAR(o2.OrderDate) = 1997
and MONTH(o2.OrderDate) = 9
AND DAY(o2.OrderDate) = 5
)
我希望在结果中只收到两条记录,而不是 228 条。如您所见,这是同一张表上的 EXISTS。先感谢您。