I have a table (ClassEnrolments) which contains student data:
StudentId Student Module Status EndDate Credits
12345678 J Bloggs Introduction Pass 2014/09/01 10
12345678 J Bloggs Advanced Pass 2014/06/01 15
23456789 T Guy Introduction Pass 2013/05/25 10
23456789 T Guy Advanced Pass 2014/03/21 15
What I want to do is return information on how many modules the student has taken in total during a set period of time, so for example, if we take the above data and look at the period 01/01/2014 to 24/11/2014 it would return the following (based on EndDate)
StudentId Student Modules Credits AnnivDate
12345678 J Bloggs 2 25 2015/06/01
23456789 T Guy 1 15 2014/05/25
This is using SQL Server 2008 - any help would be greatly appreciated.
I'm now also wondering whether using the same scenario - its possible to count the number of credits obtained from those taken modules?
Another thought! It would be useful to see some sort of anniversary date based on the students foremost module taken. This will help to establish whether the student has obtained the correct amount of credits by the anniversary date. I've toyed with the idea of the DATEADD function, but this seemed to duplicate the student information again.
DATEADD(MONTH, DATEDIFF(MONTH, 0, EndDate()) +12,0) AS AnnivDate
I understand why, as there will be multiple instances, but is there a way to look at the first instance of EndDate?