Mansoureh,
I'm sorry if I upset you. Your first post had me thinking that you were indeed a teacher, but
your second post looked a bit more suspicious. Please understand that we do get students posting
their questions in the newsgroup, looking for a quick answer, instead of showing a willingness to
tackle a problem themselves.
For the current table structure, where you indicated in your first message:
"I have a table with records of students with their grades in various
assignments. I want to do a query to find the lowest grade in each
record based on the 4 fields (grade1, grade2, grade3, grade4)."
Let me start by outlining the schema for a table that I think is close to your table. I named it
tblStudentGrades:
tblStudentGrades
Field FieldName Datatype
1 pkStudentID Autonumber (Primary Key)
2 FirstName Text (15)
3 LastName Text (20)
4 Grade1 Number / Integer
5 Grade2 Number / Integer
6 Grade3 Number / Integer
7 Grade4 Number / Integer
In this example, I am assuming that each grade can only be an integer value. If you need to
accommodate a number with a decimal, then change the datatype to Number / Single.
Add some data to your table. Then create the following union query. To create a Union query,
start with a brand new query, but do not select any tables. In query design view, click on View >
SQL View. You should see the word SELECT highlighted. Replace this word with the following SQL
statement:
SQL statement
SELECT FirstName, LastName, Grade1 AS GRADE FROM tblStudentGrades
UNION
SELECT FirstName, LastName, Grade2 AS GRADE FROM tblStudentGrades
UNION
SELECT FirstName, LastName, Grade3 AS GRADE FROM tblStudentGrades
UNION
SELECT FirstName, LastName, Grade4 AS GRADE FROM tblStudentGrades;
Save this query as: quniAllGrades
When you run it, you should see each student's name paired with each grade, as a separate record.
Create another new query. In the Show Table dialog, select the Queries tab. Select your new
union query, quniAllGrades. Click the Add button and then the Close button. Click on View > SQL
View again. Paste the following SQL statement into the SQL view:
SELECT pkStudentID, LastName, FirstName,
Min(quniAllGrades.GRADE) AS MinGrade
FROM quniAllGrades
GROUP BY pkStudentID, LastName, FirstName
ORDER BY LastName, FirstName;
Tom
___________________________________
I was so upset by your remarks that I forgot to repond to your last question.
The problem asks them to figure the Min grade for each student. I will look
up Union Query and see if I can figure it out. Thanks for your help.
TehraniCHS