Results 1 to 2 of 2
  1. #1
    AKoval is offline Novice
    Windows Vista Access 2007
    Join Date
    Jan 2013
    Posts
    9

    Query not pulling in Duplicates

    Hello. The query I created is inadvertently NOT pulling in any duplicate records in the query results. I do need the duplicate records.

    I created my queries using SQL, and I have not included any DISTINCT logic.

    So my question is, looking at the code below, how come my query is not pulling in duplicate records, and what can I do to change to code to ensure I am getting the duplicate records.

    Thanks in advance for your help!! I'm new to Access and thought I had my database figured out, but now I'm running into this major problem.

    SELECT drug_ndc_id, fill_dt, client_id, blg_reporting_cd, group_cd, net_cost_at
    FROM [2005 Q3]
    WHERE ((([2005 Q3].client_id)=[Forms]![Client ID Search].
    [List0]) AND (([2005 Q3].NET_COST_AT)>0) AND (([2005 Q3].FILL_DT)>#5/4/2005# And ([2005 Q3].FILL_DT)<#9/28/2012#))
    UNION SELECT drug_ndc_id, fill_dt, client_id, blg_reporting_cd, group_cd, net_cost_at
    FROM [2005 Q4]
    WHERE ((([2005 Q4].client_id)=[Forms]![Client ID Search].


    [List0]) AND (([2005 Q4].NET_COST_AT)>0) AND (([2005 Q4].FILL_DT)>#5/4/2005# And ([2005 Q4].FILL_DT)<#9/28/2012#))

  2. #2
    alansidman's Avatar
    alansidman is offline Indifferent
    Windows 7 32bit Access 2010 32bit
    Join Date
    Apr 2010
    Location
    Steamboat Springs
    Posts
    2,536
    change Union Select to Union All Select

    A straight Union query will eliminate duplicate entries.


    Alan

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

Similar Threads

  1. Query not pulling all records
    By noretoc in forum Queries
    Replies: 2
    Last Post: 01-11-2012, 12:37 PM
  2. Query not pulling at all
    By ricardo9211 in forum Queries
    Replies: 3
    Last Post: 02-20-2010, 04:13 AM
  3. Pulling a Query from a List Box
    By Nosaj08 in forum Queries
    Replies: 1
    Last Post: 11-09-2009, 10:27 AM
  4. Does it Matter? Pulling fields in a query
    By Canadiangal in forum Access
    Replies: 1
    Last Post: 10-01-2009, 01:53 AM
  5. Pulling out duplicates
    By FREEEEEEDOM in forum Access
    Replies: 1
    Last Post: 04-21-2009, 10:37 PM

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