SELECT date_format(crtime,'%Y-%m') as qq ,
sum(order_log.quan * mers.price) as profit,
count(orderid) as Quant
FROM order_log
left outer join mers
on order_log.tb_id = mers.tb_id
group by qq
举例中 我是两张表,一张表是销售记录order_log
另一张表是 商品价格mers
所以用了联合查询,如果你是同一张表就更简单了 不用联合查询
温馨提示:内容为网友见解,仅供参考