監(jiān)理公司管理系統(tǒng) | 工程企業(yè)管理系統(tǒng) | OA系統(tǒng) | ERP系統(tǒng) | 造價咨詢管理系統(tǒng) | 工程設(shè)計管理系統(tǒng) | 甲方項目管理系統(tǒng) | 簽約案例 | 客戶案例 | 在線試用
X 關(guān)閉

開發(fā)篇-判斷明天哪些學員在校就餐(即交了餐費)

申請免費試用、咨詢電話:400-8352-114


分析如下:

首先要計算出明天上課學員信息
然后才能判斷是否應(yīng)當在校吃飯

首先我們來看一下判斷某段日期內(nèi)上課學員的代碼:

Select distinct
StuClass.StudentID,
StuClass.StudentName
from LessonDegree,StuClass
where
LessonDegree.ClassID = StuClass.ClassID
and StuClass.ScStateID in (1,2)
and StuClass.Lessons > StuClass.CourseProgress
and LessonDegree.DateAndTime >= {@StartDate:開始日期}
and LessonDegree.DateAndTime >= {@EndDate:結(jié)束日期}

這段代碼通過分析某段時間內(nèi)的排課信息,關(guān)聯(lián)學員選班信息,然后過濾重復(fù)數(shù)據(jù),來實現(xiàn)某段時間內(nèi)上課學員的推測。其中StuClass.ScStateID in (1,2)表示學員的選班狀態(tài)一定要處于正常狀態(tài),StuClass.Lessons > StuClass.CourseProgress表示學員所購買的課程并沒有上完,distinct過濾重復(fù)的數(shù)據(jù)。

查詢某學員在某時間內(nèi)是否交過某費用代碼:

Select
count(*)
from BillItem,Bill
where
Bill.BillID = BillItem.BillID
and BillItem.ProductType = 2
and BillItem.ProductID = 18
and Bill.DateAndTime > #2012-6-1#
and Bill.DateAndTime < #2012-9-1#
and Bill.StudentID = 201300001

BillItem.ProductID 指明需要查詢的收費項編號,Bill.DateAndTime > #2012-6-1#,Bill.DateAndTime > #2012-9-1#控制交費的時間范圍,這是ACCESS語法,MS SQL需要將#號替換成’號即可。Bill.StudentID = 201300001表示查詢的學員學號。

我們將兩段代碼進行整合:

Select
StudentID as 學號,
StudentName as 姓名

from

(
Select distinct
StuClass.StudentID,
StuClass.StudentName,

(
Select
count(*)
from BillItem,Bill
where
Bill.BillID = BillItem.BillID
and BillItem.ProductType = 2
and BillItem.ProductID = 18
and Bill.DateAndTime > #2012-6-1#
and Bill.DateAndTime < #2012-9-1#
and Bill.StudentID = StuClass.StudentID
) as Num

from LessonDegree,StuClass
where
LessonDegree.ClassID = StuClass.ClassID
and StuClass.ScStateID in (1,2)
and StuClass.Lessons > StuClass.CourseProgress
and LessonDegree.DateAndTime >= {@StartDate:開始日期}
and LessonDegree.DateAndTime >= {@EndDate:結(jié)束日期}

) as tb
where Num > 0

首先我們將“查詢某學員在某時間內(nèi)是否交過某費用”的代碼做為一個子查詢加入到上課學員信息中,并且以一個虛擬列“Num”存在。然后我們再將整個查詢虛擬成一張表名稱為“tb”,最后查詢tb表,條件是Num大于0(表示至少交了一次午餐費),這樣我們就能夠精準的分析出明天需要在學校就餐的學員信息,為食堂人員提供了方便。


(把以上代碼粘貼到《泛普培訓學校管理軟件》查詢管理里,可直接使用)
發(fā)布:2007-03-30 09:49    編輯:泛普軟件 · xiaona    [打印此頁]    [關(guān)閉]