I would like to select the rows where OutgoingInvoice.TPP field not equals the SUM of Products.IncomingSUM where the OutgoingInvoice.ID = Products.OutgoingInvoice
I wrote this SQL query:
SELECT j.* FROM OutgoingInvoice AS j WHERE (((j.TPP)<>(select sum (jj.IncomingSUM) from Products as jj where jj.OutgoingInvoice = j.ID ) ));
It do not shows any rows, but there are some. What do I wrong?
You could try using WHERE NOT EXISTS instead of <>
WHERE NOT EXISTS
<>
SELECT j.* FROM OutgoingInvoice AS j WHERE NOT EXISTS(((j.TPP) = (select sum (jj.IncomingSUM) from Products as jj where jj.OutgoingInvoice = j.ID ) ));
2.1m questions
2.1m answers
60 comments
57.0k users