Select L.BookingID,InvoiceNumber,b.Operator from
view_bookingCOSTgroup L join bookings_new b
on l.BookingID=b.BookingID
where ReceivePayTime is NULL and (select count(DocName) from Document where BookingID=l.bookingID and DocTitle=l.InvoiceNumber and DocType=8)>0
view_bookingCOSTgroup L join bookings_new b
on l.BookingID=b.BookingID
where ReceivePayTime is NULL and (select count(DocName) from Document where BookingID=l.bookingID and DocTitle=l.InvoiceNumber and DocType=8)>0
錯誤不能這樣使用
改寫;
(select sum(1) from Document where BookingID=l.bookingID and DocTitle=l.InvoiceNumber and DocType=8)>0
view_bookingCOSTgroup L join bookings_new b
on l.BookingID=b.BookingID
where ReceivePayTime is NULL and (select distinct DocName from Document where BookingID=l.bookingID and DocTitle=l.InvoiceNumber and DocType=8) is not NULL
因此你只要將多條記錄轉化為一條記錄就可以了
我剛才沒看清楚.Rotaxe(程序员)寫的非常好