Union query

G

Guest

I am using the following SQL statement which i found elsewhere on this site):
SELECT NAME, Grade1 AS GRADE FROM tblStudentGrades
UNION
SELECT NAME, Grade2 AS GRADE FROM tblStudentGrades
UNION
SELECT NAME, Grade3 AS GRADE FROM tblStudentGrades
UNION
SELECT NAME, Grade4 AS GRADE FROM tblStudentGrades;

This makes a query that looks like this:
NAME GRADE
Student 1 70
Student 1 78
Student 1 80
Student 1 65
Student 2 81
Student 2 85
Student 2 80
etc., etc.
My problem with this is that if a student has the same grade twice, it will
only be listed once. Is there any way to modify this so that each grade is
listed, even if the student has more than one of the same grade?
 
A

Amy Blankenship

Try UNION ALL.

HTH;

Amy

f2rox said:
I am using the following SQL statement which i found elsewhere on this
site):

This makes a query that looks like this:
NAME GRADE
Student 1 70
Student 1 78
Student 1 80
Student 1 65
Student 2 81
Student 2 85
Student 2 80
etc., etc.
My problem with this is that if a student has the same grade twice, it
will
only be listed once. Is there any way to modify this so that each grade
is
listed, even if the student has more than one of the same grade?
 

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