为连接添加限制

时间:2016-12-13 16:03:51

标签: mysql

我正在尝试为mySQL中的一个连接添加限制。这是我的SQL:

 select v.Consultant,SUM(a.marketing_fee) marketing_fee,v.agencyref, user.colorcode 
 from valuations v 
 join status_history sh on sh.ref = v.Ref 
 join user on user.username = v.Consultant 
 join answer a on a.title = v.Ref 
 where sh.status = 'booked' and sh.date between '$from' and '$to' and v.agencyref is not null 
 group by v.consultant

由于在status_history表中有3个entrys,所以它比它应该增加了3倍。有没有办法限制状态历史表或将它们分组以获得一个结果?

0 个答案:

没有答案