SELECT DISTINCT & SELECT in SQL

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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
 
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
 
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
 

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