我有一个正在处理的查询,基本上我有 3 列:
Code: The users Code
Orders Taken: The orders which have been taken
Orders Taken From an External Call
基本上我只需要一种方法来只允许来自外部调用的订单有一个 where 子句,当我添加我的 WHERE 子句时,它对两个表都这样做。
到目前为止我的查询:
SELECT T_Temp_RestrictedDiaryCalls.AccreditedDomainCode,
Count(T_Temp_RestrictedProductSalesHistory.CustomerCode) AS [Orders Taken],
Count(T_Temp_RestrictedProductSalesHistory.CustomerCode) AS [Orders From External Calls]
FROM T_Temp_RestrictedDiaryCalls
INNER JOIN T_Temp_RestrictedProductSalesHistory
ON (T_Temp_RestrictedDiaryCalls.CustomerCode = T_Temp_RestrictedProductSalesHistory.CustomerCode)
AND (T_Temp_RestrictedDiaryCalls.CallDate = T_Temp_RestrictedProductSalesHistory.EntryDate)
GROUP BY T_Temp_RestrictedDiaryCalls.AccreditedDomainCode;
任何帮助将不胜感激。