Skip to content
Advertisement

Select Distinct in inner join with full customer record

I have two tables one with customer and another with invoices. I need to find all customer that have an more that one invoice with different days with in a period.

Invoice table: Accountnum Datein IStatus …

Customer table: Accountnum …

I have two problems:

1: I can get the customers that have more than one invoice, but I don’t know how to check if they are different days.

2: Customer shows more than one time in this query they need to show only ones.

Advertisement

Answer

A simple way to check if a given customer has invoices on two different dates is to ensure that the minimum invoice date differs from the maximum invoice date. You could write this as a join query:

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement