查詢篇-查詢顧問產(chǎn)出(即正式學員交費金額)
2013年08月02日 10:11
點擊率:9652
|
主查詢: Select Student.ConsultantName as 顧問, sum(Payment.PayMoney) as 金額, Student.ConsultantID as ShowKey from Payment,Student where Payment.StudentID = Student.StudentID and Payment.DateAndTime >= {@StartDate:開始日期} and Payment.DateAndTime <= {@EndDate:結(jié)束日期} and Payment.PaymentTypeID in (1,2) group by Student.ConsultantID , Student.ConsultantName
子查詢: Select Bill.StudentName as 所屬學員姓名, Bill.DateAndTime as 消費日期, Bill.BillTypeID as 類型, Bill.Pay as 應(yīng)收金額, Bill.Favourable as 優(yōu)惠金額, Bill.Payed as 實收金額, BillItem.ProductName as 收費項名稱 from Bill,billitem,Student Where bill.billid=billitem.billid and Bill.StudentID = Student.StudentID and Bill.DateAndTime >= {@StartDate} and Bill.DateAndTime <= {@EndDate} and Student.ConsultantID = {@ShowKey}
這個查詢在主查詢設(shè)計上,參考Payment充值表流水,達到精準目的。 但在明細上調(diào)用的是消費單信息,實現(xiàn)交費的用途查詢。如果學員存在預充值(充值尚未進行消費),或者退學等,明細里不作反映。
(把以上代碼粘貼到《麥田培訓學校管理軟件》查詢管理里,可直接使用)
|