SELECT a.agent, a.talktime, a.percentclosed,COALESCE(COUNT(b.dealamount),0),COALESCE(SUM(b.dealamount),0) , b.dealdate
FROM closers a
LEFT JOIN deals b ON a.agent = b.agent
WHERE b.dealdate IS NULL OR YEARWEEK( b.dealdate ) = YEARWEEK( NOW( ) )
GROUP BY a.agent
ORDER BY COALESCE( SUM( b.dealamount ) , 0 ) DESC
任何人都可以帮我解决这个问题,我知道它很乱,但我对此很陌生,
这适用于本周,但如果我添加 +1 来模拟未来一周,前一周有交易的每个人都不会显示,
谢谢,
约翰,
查询的图像