查詢篇-查詢當前在校學員信息
2013年09月15日 10:59
點擊率:9678
|
算法:根據(jù)班級狀態(tài)(開課中,尚未開課),搜集班級下面的學員,并且課時未上完,選班狀態(tài)正常。注意:一名學員報多門課程,會被重復統(tǒng)計。
(此查詢針對access版本,SQL版只要將其中的Now()函數(shù)替換為GetDate()即可)
主查詢:
Select count(*) as 人數(shù), Now() as ShowKey from StuClass,Class where StuClass.ClassID = Class.ClassID and StuClass.Lessons > StuClass.CourseProgress and StuClass.ScStateID in (1,2) and Class.SchoolID in ( {@SchoolID:校區(qū)} ) and ((Class.EndDate > Now() and Class.StartDate < Now()) or Class.StartDate > Now())
子查詢:
Select StuClass.StudentID as 學員編號, StuClass.StudentName as 學員姓名, StuClass.ClassID as 班級編號, StuClass.ClassName as 班級名稱, StuClass.Lessons as 已購總課時, StuClass.CourseProgress as 課程進度 from StuClass,Class where StuClass.ClassID = Class.ClassID and StuClass.Lessons > StuClass.CourseProgress and StuClass.ScStateID in (1,2) and Class.SchoolID in ( {@SchoolID} ) and ((Class.EndDate > {@ShowKey} and Class.StartDate < {@ShowKey} ) or Class.StartDate > {@ShowKey} )
(把以上代碼粘貼到《麥田培訓學校管理軟件》查詢管理里,可直接使用)
|