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