查詢(xún)篇-統(tǒng)計(jì)某段日期內(nèi)咨詢(xún)員回訪人數(shù)及回訪內(nèi)容
2013年07月21日 08:22
點(diǎn)擊率:9193
|
統(tǒng)計(jì)某段日期內(nèi)咨詢(xún)員回訪人數(shù)及回訪內(nèi)容
主查詢(xún): Select UserID as 回訪人工號(hào), TrueName as 回訪人姓名, Count(*) as 回訪次數(shù), UserID as ShowKey from Reply where
Reply.DateAndTime >= {@StartDate:開(kāi)始日期} and Reply.DateAndTime <= {@EndDate:結(jié)束日期}
group by UserID,TrueName
子查詢(xún):
Select Potential.PotentialName as 潛在學(xué)員, Potential.CourseName as 咨詢(xún)課程, Potential.Sex as 性別, Potential.Appellation as 稱(chēng)呼, Potential.Tel as 電話, Potential.MobileTel as 手機(jī), Potential.TimeRule as 上課規(guī)律, Potential.MediaName as 媒體名稱(chēng), Reply.TrueName as 回訪人姓名, Reply.Content as 回訪內(nèi)容, Reply.DateAndTime as 回訪日期 from Reply,Potential where Potential.PotentialID = Reply.PotentialID and Reply.UserID = {@ShowKey} and Reply.DateAndTime >= {@StartDate} and Reply.DateAndTime <= {@EndDate}
這是一個(gè)普通的主、子查詢(xún),需要掌握主查詢(xún)與子查詢(xún)參數(shù)的不同,以及如何通過(guò)ShowKey傳遞參數(shù)到子查詢(xún)。
(把以上代碼粘貼到《麥田培訓(xùn)學(xué)校管理軟件》查詢(xún)管理里,可直接使用)
|