문제

I have a table named INVOICES. I want to select all the invoice numbers where a certain charge code is missing. I kindly ask your help to help me out with this. All I need is something like :

Select * from Invoices where (Invoices.chargecode="FREIGHT" is not present) 

An invoice can have many charge lines but all I need to know is all those invoices user forgot to charge "FREIGHT" which cannot happen.

Many thanks. Paul

도움이 되었습니까?

해결책

Will this work for you? Assuming Invoices has an ID column which you can replace in this code:

SELECT * FROM Invoices WHERE InvoiceID NOT IN
(SELECT InvoiceID FROM Invoices WHERE chargecode = 'FREIGHT')
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 dba.stackexchange
scroll top