mickeyshelley1
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;
SELECT tblDetailVideos.Id, tblDetailVideos.txtName, tblDetailVideos.Number
FROM tblDetailVideos;
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
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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.
SELECT DISTINCT
tblDetailVideos.txtName, tblDetailVideos.Number
FROM
tblDetailVideos;
/gustav