Hi,
I have two tables Students and Origami. Origami has Foreign Key of Students table. Each student can make one or more origami for each month.
Students sample data:
StudentId, FirstName, LastName
- 187 , John , Maslow
- 196 , Crystal , Hood
- 195 , Sarah , Lewis
Origami sample data:
OrigamiId, StudentId, CreationDate, NumberOfOrigami
- 1 , 187 , 5/17/2010 1:06:55 PM , 1
- 2 , 196 , 5/22/2010 1:31:28 PM , 2
- 3 , 187 , 6/18/2010 1:51:40 PM , 2
- 4 , 187 , 6/19/2010 2:13:35 PM , 1
- 5 , 196 , 7/17/2010 2:19:44 PM , 3
- 6 , 196 , 7/19/2010 2:23:02 PM , 2
- 7 , 195 , 7/20/2010 3:04:15 PM , 3
and many more records like that format.
I'd like to ge the total number of origami of each student monthly. Something that looks like the following:
- Name ,Jan/2010 , Feb/2010 and so on
- John Maslow , 2 , 3
- Crystal Hood , 4 , 5
- Sarah Lewis , 6 , 5
Here's what I tried so far:
This query give only total origami of each student. But I want monthly count of origami for each student. Any suggestion is welcome.
Thanks.
I have two tables Students and Origami. Origami has Foreign Key of Students table. Each student can make one or more origami for each month.
Students sample data:
StudentId, FirstName, LastName
- 187 , John , Maslow
- 196 , Crystal , Hood
- 195 , Sarah , Lewis
Origami sample data:
OrigamiId, StudentId, CreationDate, NumberOfOrigami
- 1 , 187 , 5/17/2010 1:06:55 PM , 1
- 2 , 196 , 5/22/2010 1:31:28 PM , 2
- 3 , 187 , 6/18/2010 1:51:40 PM , 2
- 4 , 187 , 6/19/2010 2:13:35 PM , 1
- 5 , 196 , 7/17/2010 2:19:44 PM , 3
- 6 , 196 , 7/19/2010 2:23:02 PM , 2
- 7 , 195 , 7/20/2010 3:04:15 PM , 3
and many more records like that format.
I'd like to ge the total number of origami of each student monthly. Something that looks like the following:
- Name ,Jan/2010 , Feb/2010 and so on
- John Maslow , 2 , 3
- Crystal Hood , 4 , 5
- Sarah Lewis , 6 , 5
Here's what I tried so far:
VB.NET:
Dim query = From st In db.Students _
Join or In db.Origami On or.StudentId Equals st.StudentId _
Group By or.StudentId Into TotalOrigami = Sum(or.NumberOfOrigami) _
Select StudentId, TotalOrigami
This query give only total origami of each student. But I want monthly count of origami for each student. Any suggestion is welcome.
Thanks.