Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

crosstab queries:- couting values

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
I am making a marks scheme for my school, and they want a break down of the grade acheived by each student. i have a query with the level/grade for each student which is on a numerical basis 1-8. I want a query that seperates that shows the number of people achieving each level for each set.
Eg if there were 10 males , 1 got L1, 3 got L3, 4 L5, 2 L7 and 10 females 2 L2, 1 L4, 3 L5, 2 L6, 2 L8 then I would have a table looking like....

Grades | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 |
------------------------------------------------------------
Male | 1 | 0 | 3 | 0 | 4 | 0 | 2 | 0 |
Female | 0 | 2 | 0 | 1 | 3 | 2 | 0 | 2 |

I've tried using a crosstab but it does not seem to work. The grades come from another query as they are worked out from an average of a number of peices of work. Hope you can help from what i've said.
thanks
 
My Table

StuName StuSex StuGrade

John D. Rockefeller M L1
Arron Guggenhiem M L3
Buffalo Bill M L3
Wyatt Eyrp M L3
Bruce Smith M L5
Brad Johnson M L5
Terrell Davis M L5
Brett Conway M L5
Gary Sibley M L7
Jack Sprat M L7
Mary Smith F L2
Jane Pauley F L2
Sara Jackson F L4
Monica Selles F L5
Terra Lapinsky F L5
Anne Thompson F L5
Roberta Janes F L6
Alice N. Wonderland F L6
M. Goose F L8
Elixabeth Q. England F L8


Results:
StuSex L1 L2 L3 L4 L5 L6 L7 L8
F 2 1 3 2 2
M 1 3 4 2


MyQuery.SQL
TRANSFORM Count(tblStuGrade.StuName) AS CountOfStuName
SELECT tblStuGrade.StuSex
FROM tblStuGrade
GROUP BY tblStuGrade.StuSex
PIVOT tblStuGrade.StuGrade;


'------------------------------------------------------
Since I do not know how your app is set up (names of thinggggggys, I created a sample which (i think) matches the descriptions of your progress to date. These are included just so you can relate my table/field names to your app names (tables | queries / Field names). The results look o.k. from here.



MichaelRed
mred@duvallgroup.com
There is never time to do it right but there is always time to do it over
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top