Welcome to SPN

Register and Join the most happening forum of Sikh community & intellectuals from around the world.

Sign Up Now!

Prevent Duplicates from Union Query

Discussion in 'Information Technology' started by PPCO, Jul 28, 2006.

  1. PPCO

    PPCO
    Expand Collapse
    Guest

    I have a simple Union Query, but it returns duplicates from my 2 tables. I am
    using just the Union Select not Union All Select. Is there an easy way to
    prevent the duplicates?

    SQL:

    Select Customerreffullname as customer, RequestDate as
    RequestDateorNumberofDayssincelastpickup, RequestType
    from qrypickuprequestMMCO

    UNION select Customer, Dayssincelastpickup as
    RequestDateorNumberofDayssincelastpickup, RequestType
    from qryMutualInvoiceOrderLineLastPickupPastDeadline;
     
  2. Loading...

    Similar Threads Forum Date
    How to prevent sikh erosion? Blogs Oct 21, 2015
    Leisure Stomach Protection / Prevention for travelling to India?? Business, Lifestyle & Leisure Oct 18, 2013
    Controversial Panch Pardhani leader arrested; prevented from attending Shaheedi samagam of Bhai Jaspal Singh Hard Talk Mar 30, 2013
    World Women must play greater role in conflict prevention, UN says Breaking News Oct 28, 2011
    Sikh Coalition Bullying Prevention Summit. Register Today! Sikh Organisations Oct 19, 2011

  3. SusanV

    SusanV
    Expand Collapse
    Guest

    You could do SELECT DISTINCT * FROM YourUnionQuery...
    --
    hth,
    SusanV

    "PPCO" <PPCO@discussions.microsoft.com> wrote in message
    news:C4E358FA-B82E-4DC4-AC38-720112A0818A@microsoft.com...
    >I have a simple Union Query, but it returns duplicates from my 2 tables. I
    >am
    > using just the Union Select not Union All Select. Is there an easy way to
    > prevent the duplicates?
    >
    > SQL:
    >
    > Select Customerreffullname as customer, RequestDate as
    > RequestDateorNumberofDayssincelastpickup, RequestType
    > from qrypickuprequestMMCO
    >
    > UNION select Customer, Dayssincelastpickup as
    > RequestDateorNumberofDayssincelastpickup, RequestType
    > from qryMutualInvoiceOrderLineLastPickupPastDeadline;
    >
    >
     
  4. Jerry Whittle

    Jerry Whittle
    Expand Collapse
    Guest

    A UNION query can not return duplicate records. Something in the record MUST
    be different for them to be returned. So you need to define what you consider
    a duplicate. Is it one field or a combination of more than one field? Which
    fields?
    --
    Jerry Whittle
    Light. Strong. Cheap. Pick two. Keith Bontrager - Bicycle Builder.


    "PPCO" wrote:

    > I have a simple Union Query, but it returns duplicates from my 2 tables. I am
    > using just the Union Select not Union All Select. Is there an easy way to
    > prevent the duplicates?
    >
    > SQL:
    >
    > Select Customerreffullname as customer, RequestDate as
    > RequestDateorNumberofDayssincelastpickup, RequestType
    > from qrypickuprequestMMCO
    >
    > UNION select Customer, Dayssincelastpickup as
    > RequestDateorNumberofDayssincelastpickup, RequestType
    > from qryMutualInvoiceOrderLineLastPickupPastDeadline;
    >
    >
     

Share This Page