Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9177185
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T17:16:10+00:00 2026-06-17T17:16:10+00:00

I have exhausted all examples I can find and I am still not getting

  • 0

I have exhausted all examples I can find and I am still not getting the results I need.

I have an invoice table where I need to find any instance where the same invoice number is used on more than one customer. An invoice number can occur multiple times in the table and each record is distinguished by invoice and invoice seq no, but there should only be one customer per invoice, but some errors have crept in.

What I need is a report of only those invoice that have two or more customers. In the data below Cust 45001301 should not be the customer number for Invoice 708, seq 3.

Cust No Invoice No  Seq No  Input Date
700180  708 1   9/30/2007
700180  708 2   9/30/2007 
45001301    708 3   9/30/2007
700180  708 4   9/30/2007
700190  709 1   9/30/2007
700190  709 2   9/30/2007

What I have tried to do is just get a simple group by query to show me only those invoices with more than one customer much like this-

[Invoice No] [Cust no]
   708          700180 
   708        45001301

But I ONLY want to see those with two or more customers, so in the above example I would not see the entry for invoice 709 because it only has the one customer.

[Invoice No] [Cust no]
   708          700180 
   708        45001301
   709          700190
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T17:16:11+00:00Added an answer on June 17, 2026 at 5:16 pm

    First create a query which returns all distinct combinations of [Invoice No] and [Cust no]. Then use that as a subquery where you count the number of customers per [Invoice No] and add a HAVING clause to limit the output to only those where the count is greater than one.

    SELECT sub.[Invoice No], Count(*) AS customers
    FROM
        (
            SELECT DISTINCT [Invoice No], [Cust no]
            FROM Invoices
        ) AS sub
    GROUP BY sub.[Invoice No]
    HAVING Count(*) > 1;
    

    If you then need to see which customers where duplicated for those invoices, INNER JOIN that query back to the Invoices table.

    SELECT DISTINCT i.[Invoice No], sub2.customers, i.[Cust No]
    FROM
        Invoices AS i
        INNER JOIN
        (
            SELECT sub.[Invoice No], Count(*) AS customers
            FROM
                (
                    SELECT DISTINCT [Invoice No], [Cust no]
                    FROM Invoices
                ) AS sub
            GROUP BY sub.[Invoice No]
            HAVING Count(*) > 1
        ) AS sub2
        ON i.[Invoice No] = sub2.[Invoice No];
    

    With Access 2007 and your sample data in a table named Invoices, that query gives me this result set:

    Invoice No customers Cust No
    708                2   700180
    708                2 45001301
    

    If you actually wanted to see all the data for those duplicate invoice numbers, change the first line of the second query to this:

    SELECT i.[Invoice No], sub2.customers, i.[Cust No], i.[Seq No], i.[Input Date]
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have exhausted my efforts to find any useful information about the IAuthorizeRemotingConnection interface
I'm not even sure if this is possible, but I've exhausted all of my
I have 5000 vectors which are held in 5000 files. I need to find
I have exhausted all avenues in trying to solve this problem and in the
Iv been struggling with this for a while now an I have exhausted all
I've been trying to fix this problem for a while and have exhausted all
As a self-taught (poorly) PHP coder, I have exhausted all the trial-and-error possibilities so
I have searched google and exhausted a fair bit of my time trying to
This seems simple but I've exhausted my Google search patience. I have a RelativeLayout
Have done quite a bit of searching for a guide (of any substance) for

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.