select customerid from saleorder where status='4' and status!-'5'
SELECT * FROM [Table] a WHERE [STATUS]=4 AND customerid NOT IN(SELECT customerid FROM [Table] WHERE customerid=a.customerid AND [STATUS]=5)
SELECT * FROM saleorder a WHERE STATUS='4' AND customerid NOT IN(SELECT customerid FROM saleorder b WHERE b.customerid=a.customerid AND STATUS='5')
select customerid from saleorder where [status]=4 and [status]<>5
select customerid from saleorder a where STATUS='4' and customerid not in(select customerid from saleorder b where b.customerid=a.customerid and STATUS='5');或者:select customerid from saleorder where STATUS='4' EXCEPT select customerid from saleorder where STATUS='5';其中(EXCEPT表示差集)
[STATUS]=4 AND customerid NOT IN(SELECT customerid FROM [Table] WHERE customerid=a.customerid AND [STATUS]=5)
STATUS='4' AND customerid NOT IN(SELECT customerid FROM saleorder b WHERE b.customerid=a.customerid AND STATUS='5')
from saleorder a
where STATUS='4' and customerid not in(select customerid from saleorder b where b.customerid=a.customerid and STATUS='5');或者:select customerid
from saleorder
where STATUS='4'
EXCEPT
select customerid
from saleorder
where STATUS='5';其中(EXCEPT表示差集)