Question

Good day,

I am struggling with suppressing specific records on my report. My report lists certain invoices that do not have 2 rows in the database. The reason it needs to have two rows is because one row is the invoice and the other is the receipt applied to that invoice. My problem is trying to create a new report to check if the amounts on both records are equal and if not then they must show on the report thus displaying only those invoices with unequal amounts.

Example

This is fine because each invoice needs two rows. The last line amount does not match the amount of the record above it, they have the same Inv. no.'s and are in the same table but the wrong amount is there. I want to isolate it and only show the Inv no.'s of the transactions with unequal amounts.

Please let me know if more clarity is needed. This seemed simple to begin with but I'm just not getting it right.

Thanks.

Was it helpful?

Solution

Try something like

select inv
from YourTable
group by inv
having count(distinct amount) > 1

You group all the invoices together with the group by clause, then count the number of different amounts in each group. Where this is more than 1, then the amounts are different.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top