查询篇-统计某段日期内咨询员回访人数及回访内容
2013年07月21日 08:22
点击率:9298
|
统计某段日期内咨询员回访人数及回访内容
主查询: Select UserID as 回访人工号, TrueName as 回访人姓名, Count(*) as 回访次数, UserID as ShowKey from Reply where
Reply.DateAndTime >= {@StartDate:开始日期} and Reply.DateAndTime <= {@EndDate:结束日期}
group by UserID,TrueName
子查询:
Select Potential.PotentialName as 潜在学员, Potential.CourseName as 咨询课程, Potential.Sex as 性别, Potential.Appellation as 称呼, Potential.Tel as 电话, Potential.MobileTel as 手机, Potential.TimeRule as 上课规律, Potential.MediaName as 媒体名称, Reply.TrueName as 回访人姓名, Reply.Content as 回访内容, Reply.DateAndTime as 回访日期 from Reply,Potential where Potential.PotentialID = Reply.PotentialID and Reply.UserID = {@ShowKey} and Reply.DateAndTime >= {@StartDate} and Reply.DateAndTime <= {@EndDate}
这是一个普通的主、子查询,需要掌握主查询与子查询参数的不同,以及如何通过ShowKey传递参数到子查询。
(把以上代码粘贴到《麦田培训学校管理软件》查询管理里,可直接使用)
|