One record from many based upon single field

K

kemosabe

I have a query that returns more than one record per unique field (AssocID).
I would like to return only 1 (first?) record per unique field. Is there an
easy way to do this? Thanks!
 
M

Michel Walsh

SELECT AssocID, LAST(otherField1), LAST(otherField2), LAST(... )
FROM somewhere
GROUP BY AssocID




Vanderghast, Access MVP
 
J

John W. Vinson

I have a query that returns more than one record per unique field (AssocID).
I would like to return only 1 (first?) record per unique field. Is there an
easy way to do this? Thanks!

SELECT TOP 1 AssocID, thisfield, thatfield, theotherfield
FROM <whatever>
ORDER BY <some field>
 
M

Michel Walsh

Ah, I haven't understood the question like this, and indeed, that returns
ONE record from the whole table.


Vanderghast, Access MVP
 
C

cixelsyd

I have a similar problem. I have a table containing transaction data for many
items (Partno). Each item may have several entries in the table due to
transactions on different dates (TDate).
I wish to select the complete record for each item for the most recent
transactions (TDate) from a table containing many records. How do I structure
the query?

Table

Partno1 Date1 DataX DataY
Partno1 Date2 DataX DataY
Partno1 Date3 DataX DataY > most recent date
Partno2 Date1 DataX DataY
Partno3 Date1 DataX DataY

I wish to return

Partno1 Date3 DataX DataY > most recent date
Partno2 Date1 DataX DataY
Partno3 Date1 DataX DataY
 

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

Top