Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6750277
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T12:47:20+00:00 2026-05-26T12:47:20+00:00

I am getting double results for every part…so I’m obviously not using Distinct right

  • 0

I am getting double results for every part…so I’m obviously not using Distinct right here or need to use grouping?

example:

select DISTINCT p.PartNum,
                p.PartID,
                pn.Name,
                d.[Description],
                n.Note as PartNote
from Part p
            join PartName pn on pn.PartNameID = p.PartNameID
            join ApplicationPaint ap on ap.partID = p.PartID
            join [Application] a on a.ApplicationID = ap.ApplicationID
            join [Description] d on d.DescriptionID = ap.DescriptionID
            join Note n on n.NoteID = a.NoteID
            join MYConfig mmy on mmy.MMYConfigID = a.MYConfigID
            join Model mo on mo.ModelID = mmy.ModelID
where mmy.ModelId = 2673
and substring(n.Note, CHARINDEX(']', n.Note) + 2, LEN(n.Note))= 'Johnson'

results:

T50015  765963  Some Part Name  SomeNoteA   [342] Johnson
T50015  765963  Some Part Name  SomeNoteA   [343] Johnson
T60024  766068  Some Part Name  SomeNoteB   [342] Johnson
T60024  766068  Some Part Name  SomeNoteB   [343] Johnson
T60231  766093  Some Part Name  SomeNoteA   [342] Johnson
T60231  766093  Some Part Name  SomeNoteA   [343] Johnson
T60232  766094  Some Part Name  SomeNoteA   [342] Johnson
T60232  766094  Some Part Name  SomeNoteA   [343] Johnson
T70134  766150  Some Part Name  SomeNoteA   [342] Johnson
T70134  766150  Some Part Name  SomeNoteA   [343] Johnson
T70230  766153  Some Part Name  SomeNoteC   [342] Johnson
T70230  766153  Some Part Name  SomeNoteC   [342] Johnson
T70230  766153  Some Part Name  SomeNoteC   [343] Johnson
Y50078  766253  Some Part Name  SomeNoteH   [342] Johnson
N30026  766352  Some Part Name  SomeNoteT   [342] Johnson
N30026  766352  Some Part Name  SomeNoteT   [343] Johnson
N50041  766465  Some Part Name  SomeNoteK   [342] Johnson
N50041  766465  Some Part Name  SomeNoteK   [343] Johnson
N60176  766499  Some Part Name  SomeNoteX   [342] Johnson
N60176  766499  Some Part Name  SomeNoteX   [343] Johnson
N60750  766503  Some Part Name  SomeNoteU   [342] Johnson
N60750  766503  Some Part Name  SomeNoteU   [343] Johnson

so I’m getting dups even triples on every PartNumber

T70230  766153  Some Part Name  SomeNoteC   [342] Johnson
T70230  766153  Some Part Name  SomeNoteC   [342] Johnson
T70230  766153  Some Part Name  SomeNoteC   [343] Johnson

T50015  765963  Some Part Name  SomeNoteA   [342] Johnson
T50015  765963  Some Part Name  SomeNoteA   [343] Johnson

so what I want to see is this:

T50015  765963  Some Part Name  SomeNoteA   [342] Johnson
T60024  766068  Some Part Name  SomeNoteB   [342] Johnson
T60231  766093  Some Part Name  SomeNoteA   [342] Johnson
T60232  766094  Some Part Name  SomeNoteA   [342] Johnson
T70134  766150  Some Part Name  SomeNoteA   [342] Johnson
T70230  766153  Some Part Name  SomeNoteC   [342] Johnson
Y50078  766253  Some Part Name  SomeNoteH   [342] Johnson
N30026  766352  Some Part Name  SomeNoteT   [342] Johnson
N50041  766465  Some Part Name  SomeNoteK   [342] Johnson
N60176  766499  Some Part Name  SomeNoteX   [342] Johnson
N60750  766503  Some Part Name  SomeNoteU   [342] Johnson

So I want only one unique row for each Unique part number, not dup part number rows showing here.

So to put it in other words for example I want this (one row only for a partID):

T70230  766153  Some Part Name  SomeNoteC   [342] Johnson

vs. dups:

T70230  766153  Some Part Name  SomeNoteC   [342] Johnson
T70230  766153  Some Part Name  SomeNoteC   [342] Johnson
T70230  766153  Some Part Name  SomeNoteC   [343] Johnson
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T12:47:21+00:00Added an answer on May 26, 2026 at 12:47 pm

    You’ve omitted part names and notes from your example, but I believe DISTINCT means that it should omit rows from the results where all of the columns you’ve specified are duplicated, not any.

    So since you’ve specified p.PartNum, p.PartID, pn.Name, d.[Description], and n.Note, only rows where all of those values are duplicated will be removed.

    For example, you’ve said your results included:

    T70230  766153  Some Part Name  SomeNoteC   [342] Johnson
    T70230  766153  Some Part Name  SomeNoteC   [342] Johnson
    T70230  766153  Some Part Name  SomeNoteC   [343] Johnson
    

    If those rows were really:

    T70230  766153  CoolWidget1  "So much fun!"     [342] Johnson
    T70230  766153  CoolWidget1  "Buy one today!"   [342] Johnson
    T70230  766153  CoolWidget2  "Buy one today!"   [343] Johnson
    

    Then all three rows will remain, as none have the exact same values for all five of the column names you’ve listed for the DISTINCT operator.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm getting some strange performance results here and I'm hoping someone on stackoverflow.com can
Im trying to convert radians to degrees, but im not getting the same results
I need some help getting correct results on fraction results. After adding them together
Why am I getting this result? [TestMethod] public void nan_test() { Assert.AreEqual(1, double.NaN, 1E-1);
Getting started with NHibernate How can I generate identity fields in nHibernate using Hilo
I'm querying a database and some of the results I'm getting are null. I'm
I'm seeing strange results when doing a string.Format( C ); E.g. double val =
I'm baffled by the results I'm getting from FFT and would appreciate any help.
I expected this to be simple, but I'm getting some strange results. I'd appreciate
I'm getting some odd results where 2 identical functions (one in PHP and one

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.