I am searching Invoice Itemized Table for Invoices with Quantity having >0 and <0. Invoice Itemized table contains details of all the items in an Invoice. How can I write a query that gives all the invoices that have Quantity of items >0 and <0.
I am searching Invoice Itemized Table for Invoices with Quantity having >0 and <0.
Share
How about something like this? This uses two queries. The first finds all the invoices with Negative Quantities. Then it APPLY’s the second query to find from that list of invoices only those that also have positive quantities.
Here is another version that uses CTEs: