SELECT DISTINCT & SELECT in SQL

D

Dragon_Silveroak

I have a query that I want to select all the unique records in one field, and
show all fields for those records.

The SQL Im trying to use is...

SELECT [Emp# Field],[Date Field],[O Field], [MinWorked]
SELECT DISTINCT [I Field]
FROM punch5duplicates;

That is returning a syntax error.
Thanks in advance for the help.
DS
 
M

Michel Walsh

Hi,



You can't have two SELECT main clauses.


SELECT f1, LAST(f2), LAST(f3), LAST(f4)
FROM myTable
GROUP BY f1



would display f1 without repetition, and list ONE (random) record (fields
f2, f3, f4) associated to each f1 value.



Hoping it may help,
Vanderghast, Access MVP
 
D

Dragon_Silveroak

That is perfect, Thank you!

Michel Walsh said:
Hi,



You can't have two SELECT main clauses.


SELECT f1, LAST(f2), LAST(f3), LAST(f4)
FROM myTable
GROUP BY f1



would display f1 without repetition, and list ONE (random) record (fields
f2, f3, f4) associated to each f1 value.



Hoping it may help,
Vanderghast, Access MVP


Dragon_Silveroak said:
I have a query that I want to select all the unique records in one field,
and
show all fields for those records.

The SQL Im trying to use is...

SELECT [Emp# Field],[Date Field],[O Field], [MinWorked]
SELECT DISTINCT [I Field]
FROM punch5duplicates;

That is returning a syntax error.
Thanks in advance for the help.
DS
 
Top