22,210
社区成员
发帖
与我相关
我的任务
分享
select
mt.merchant_id,mb.name as merchant_name,sum(mt.price*mt.buycount) as total,date_format(mt.regdate,'%Y-%m') as regdate
from sys_cart mt,sys_merchant mb
where mt.payflag!=0
and mt.merchant_id=1
and DATE_FORMAT(mt.regdate,'%Y')='2014'
group by date_format(mt.regdate,'%Y-%m')
mb表没有关联,难道所有的merchant_name都指向一个name。
不要group by看下你的数据。