Meskipun saya pikir JOIN
kriteria sangat tidak mungkin, sepertinya Anda mencoba melakukan ini?
EDIT:Saya telah memodifikasi JOIN
kriteria tetapi inilah yang Anda cari.Grouping By
kolom yang OR
'd aneh.
;WITH MinOrderDates AS
(
SELECT CustID
,OrderDate = MIN(OrderDate)
FROM Orders
GROUP BY CustID
)
UPDATE C
SET FirstOrderDate = MIN(O.OrderDate)
FROM Customers C
JOIN MinOrderDates O ON C.Id = O.CustID
Seperti inilah tampilan kueri Anda dengan OR
s
;WITH MinOrderDates AS
(
SELECT ShipperId
,PickupId
,ConsigneeId
,DeliveryId
.BillingId
,OrderDate = MIN(OrderDate)
FROM Orders
GROUP BY ShipperId
,PickupId
,ConsigneeId
,DeliveryId
.BillingId
)
UPDATE C
SET FirstOrderDate = MIN(O.OrderDate)
FROM Customers C
JOIN MinOrderDates O ON o.ShipperId = C.Id or
o.PickupId = C.Id or
o.ConsigneeId = C.Id or
o.DeliveryId = C.Id or
o.BillingId = C.Id
EDIT:Meskipun saya kesulitan menemukan kesalahan dengan sintaks yang Anda posting.