Results 1 to 4 of 4
  1. #1
    MsAxes is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Oct 2021
    Posts
    100

    How to identify if a value in a column is found more than once?

    Hi all

    I have a query that first groups the customers different account types and sums up the balances (simple). The subquery below returns the max balance for a customer for that specific product they have. I just realized that 4 of the 10k records this runs for have the same balance therefore it returns more than one ssn with the same balance (this causes a duplication in another query).




    Code:
    SELECT Table1.*FROM Table1 INNER JOIN (SELECT SSN, Max(Sum_of_Bal) AS Max_Bal FROM Table1 GROUP BY SSN)  AS Table2 ON (Table1.Sum_of_Bal = Table2.Max_Bal) AND (Table1.SSN = Table2.SSN);
    How can I add a column that tells me if that ssn is returned more than once?

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,525
    something like this:

    Code:
    public function getCountOfCustID(pvID)
    getCountOfCustID=Dcount("*", "qsMyQuery","[CustID]=" & pvID )
    end function

  3. #3
    MsAxes is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Oct 2021
    Posts
    100
    I'll give that a try - what is pvID?

  4. #4
    MsAxes is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Oct 2021
    Posts
    100
    I couldn't get the function to work (not sure what pvID is) so I just created a third (I hate to have this many) subquery where I inner join the SQL above to get the count by SSN and it worked.

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

Similar Threads

  1. Replies: 5
    Last Post: 08-26-2022, 02:17 PM
  2. How Do I Identify A Field?
    By lccrews in forum Modules
    Replies: 3
    Last Post: 01-04-2018, 05:18 PM
  3. Replies: 2
    Last Post: 07-03-2017, 09:10 AM
  4. Replies: 6
    Last Post: 11-18-2013, 07:52 AM
  5. Identify which criteria was used
    By ridersjs in forum Queries
    Replies: 2
    Last Post: 11-29-2011, 10:44 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