"Constant" value placed in all records?

J

jwkratz

I'm working on a relatively simple query using Access XP. Here's m
goal:

Display a list of all students. Include student ID, name, and age. I
addition, include in each record the minimum age out of all th
students.

For example:

ID..........Name..........Age..........MinAge
1...........Jim...........21...........18
2...........Bob...........18...........18
3...........Steve.........25...........18
4...........Jane..........22...........18

I've tried making a separate query to select the minimum age an
joining it to another query that selects all records from the student
table, but I receive an aggregate function error. I feel like this ca
be solved with a join, but I cannot seem to determine how, as there i
no real "parent" field for the minimum query.

Thanks very much for your time
 
J

John Vinson

I'm working on a relatively simple query using Access XP. Here's my
goal:

Display a list of all students. Include student ID, name, and age. In
addition, include in each record the minimum age out of all the
students.

For example:

ID..........Name..........Age..........MinAge
1...........Jim...........21...........18
2...........Bob...........18...........18
3...........Steve.........25...........18
4...........Jane..........22...........18

Two solutions:

SELECT ID, [Name], Age, DMin("[Age]", "tablename") AS MinAge
FROM tablename
ORDER BY ID;

or the subquery approach:

SELECT ID, [Name], Age, (SELECT Min([Age] FROM tablename) AS MinAge
FROM tablename
ORDER BY ID;
 

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