表链接后进行计算

select t.id,t.userId,taskType,reward,servicesTime,timeLength, publicTime,notes,location,headPicture,tu.counts
from task t left join user u on t.userId=u.id  left join (select taskId , count(userId) counts from taskuserrelation GROUP BY taskId) tu on tu.taskId=t.id where servicesTime>'2015-09-18'
 order by servicesTime asc;

你可能感兴趣的:(表链接后进行计算)