Link to home
Start Free TrialLog in
Avatar of mickeyshelley1
mickeyshelley1Flag for United States of America

asked on

Select Distinct access 2003 Query

I need to modify the query below to only show distinct values in the number field, in other words if there are 25 records showing the number 50 in the number field i only want it to show the number 50 once,

SELECT tblDetailVideos.Id, tblDetailVideos.txtName, tblDetailVideos.Number
FROM tblDetailVideos;
Avatar of Gustav Brock
Gustav Brock
Flag of Denmark image

This should do:

SELECT DISTINCT
    tblDetailVideos.txtName, tblDetailVideos.Number
FROM
    tblDetailVideos;

/gustav
The problem with DISTINCT queries is that it will only return DISTINCT combinations of fields.  So if you want all of those other fields in the result set, you may still get duplicates from the [Number] field.

The syntax is simple, simply add DISTINCT as the predicate to the list of fields:

SELECT DISTINCT Field1, Field2, FieldN
FROM yourTable
ASKER CERTIFIED SOLUTION
Avatar of PatHartman
PatHartman
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
My answer solves the problem.  Using the Group By, you can get  a single instance of the requested column and the "first" instance of the other fields.  The Distinct keyword would only work if all instances of the additional columns had no variations.