Welcome to SPN

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

Sign Up Now!
  1. Monthly (Recurring) Target: $300 :: Achieved: $95
      Become a Supporter    ::   Make a Contribution   

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;
    >
    >
     
Since you're here... we have a small favor to ask...

More people are visiting & reading SPN than ever but far fewer are paying to sustain it. Advertising revenues across the online media have fallen fast. So you can see why we need to ask for your help. Donating to SPN's is vote for free speech, for diversity of opinions, for the right of the people to stand up to religious bigotry. Without any affiliation to any organization, this constant struggle takes a lot of hard work to sustain as we entirely depend on the contributions of our esteemed writers/readers. We do it because we believe our perspective matters – because it might well be your perspective, too... Fund our efforts and together we can keep the world informed about the real Sikh Sikhi Sikhism. If everyone who writes or reads our content, who likes it, helps us to pay for it, our future would be much more secure. Every Contribution Matters, Contribute Generously!

    Become a Supporter      ::     Make a Contribution     



Share This Page