Return one from many

  • Thread starter Thread starter simoNamibia
  • Start date Start date
S

simoNamibia

Lets say we have a table containing names and their heights. In the table
there are 10 John's and 10 Mary's all of varying heights, how would one query
this table in order to return only the one John and the one Mary whose height
is the smallest?

Thanks
 
Substitute your table name and field names but this is the SQL

SELECT Heights.PersonName, Min(Heights.Height) AS MinOfHeight
FROM Heights
GROUP BY Heights.PersonName
HAVING (((Heights.PersonName)="John" Or (Heights.PersonName)="Mary"));

Or in query design, put the person and the height in as columns. Click the
Totals button, leave person as group by but change height to Min.
Enter "John" or "Mary" as criteria
 

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