我有一个样本呼叫中心系统的5个表
表是
我有两种类型的员工
首先打电话告诉客户新的优惠,然后在Call_Log
表中保存呼叫数据
第二类员工根据通话状态创建发票(如果客户想购买某些产品,第一位员工将与客户结束通话,第二位员工将再次打电话给他并创建发票)
我想选择
答案 0 :(得分:1)
我认为这是你的答案......
其他请发表评论。会帮助你
第一次通话的员工
select Employee.ID, Employee.Name from Call_Log
inner join Employee on Call_Log.EmployeeID = Employee.ID
where Call_Log.Call_Status = 'ReadyToBuy' /*or some constants which mention the status, whether the customer ready or not to buy*/
创建发票的员工
select Employee.ID, Employee.Name from Invoic
inner join Employee on Invoic.EmployeeID = Employee.ID
发票
select Invoic.*, Invoic_Details.ProductName from Invoic
inner join Invoic_Details on Invoic.ID = Invoic_Details.InvoiceID
发票日期
select Date from Invoic
答案 1 :(得分:0)
select call_log.employee_id ,invoice.employee_id,invoice.id,invoice.date
from call_log inner join invoice on call_log.id=invoice.call_log_id
where call_status='ReadytoBuy';
我认为这应该有用。
答案 2 :(得分:0)
试试这个..
SELECT t2.NAME
,t5.NAME
,t3.ID
,t3.creation_date
FROM @call_log t1
INNER JOIN @Employee t2 ON t2.employee_id = t1.employee_id
AND STATUS = 'invoiced'
INNER JOIN @invoice t3 ON t3.call_log_id = t1.ID
LEFT JOIN @call_log t4 ON t1.num_id = t4.num_id
AND t4.STATUS = 'started_call'
LEFT JOIN @Employee t5 ON t4.employee_id = t5.employee_id