Query to find "Unique" entries in Fields ??

  • Thread starter Thread starter Will
  • Start date Start date
W

Will

Is there a way to create a Query that will find only one occurance of each
entry in a field?

For Example... A table that has Customer Names in one of its fields. There
are multiple records for some Customes... so that name will occur multiple
times in the table in the Customer Name field.

Can I write a querry to display only one occurance of each Customer Name?

If so how?

(Then I want to convert that to a table of unique Customer names)

Thanks for any help on this.

Will
 
Create a group by query that display the customer name, with a count on a
customer name that equal to 1

SELECT MyTableName.[Customer Name]
FROM MyTableName
GROUP BY MyTableName.[Customer Name]
HAVING Count(MyTableName.[Customer Name])=1
 
You can use the DISTINCT keyword like:

SELECT DISTINCT CustName
FROM [MyTableWithRepeatedNames]

and the Query will return each name only once.
 
In the Query design window:
- View>Properties (or F4)
- if the resulting popup caption says "Field Properties", click a blank area
of the query design window until the caption reads "Query Properties"
- Set the "Unique Values" property to Yes

(FYI: This changes the SQL of your query from "SELECT..." to "SELECT
DISTINCT...", so if you are comfortable editing SQL, you could do it that
way.)

HTH,
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top