Results 1 to 4 of 4
  1. #1
    Carol Frey is offline Novice
    Windows 10 Access 2013 64bit
    Join Date
    Sep 2017
    Posts
    2

    Query design help

    I want to query where one field is the same and another field is different. For example, where invoice number field is the same and the vendor number field is different.

    I got the first part as: In (SELECT [Invoice Number] FROM [combo] As Tmp GROUP BY [Invoice Number] HAVING Count(*)>1 ) but I can't figure out how to at the same time get where the vendor number field is different.



    Any help is appreciated.

    Thanks,

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,525
    SELECT * from tData , tData as tData1 where
    tData.[invoice number]=
    tData1.[invoice number]
    and
    tData.[vendor number]<> tData1.[vendor number]

  3. #3
    Carol Frey is offline Novice
    Windows 10 Access 2013 64bit
    Join Date
    Sep 2017
    Posts
    2
    Thank you, but I am trying to find the same and different data in the same file, not from two different files.

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,931
    You want to list invoice numbers with multiple vendors and you want to show the vendors as well?

    Ranman's SQL is using only 1 table. He is doing a Cartesian relationship self-join by using alias name - tData AS tData1

    Try another approach:

    SELECT * FROM table WHERE [Invoice Number] IN (SELECT [Invoice Number] FROM table WHERE Count([Vendor])>1 GROUP BY [Invoice Number]);

    However, this won't work if there can be duplicate invoice/vendor pairs in the table. Will that be possible? Might provide sample data.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Help! Query design
    By dmlaz68 in forum Queries
    Replies: 5
    Last Post: 09-03-2015, 03:34 PM
  2. Replies: 1
    Last Post: 05-02-2014, 09:29 AM
  3. Query\db design help
    By BRZ-Ryan in forum Queries
    Replies: 13
    Last Post: 01-06-2014, 08:56 PM
  4. Query design
    By joanne2468 in forum Queries
    Replies: 3
    Last Post: 07-30-2013, 09:29 PM
  5. Query Design
    By Daryl2106 in forum Access
    Replies: 7
    Last Post: 12-05-2012, 09:55 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums