SELECT *,(SELECT COUNT(*) FROM yd_order o WHERE FROM_UNIXTIME(o.`ctime`,'%Y-%m')='2016-06' AND o.uid=c.cus_id) AS order_num_m , (SELECT SUM(o.`pay_fee`) FROM yd_order o WHERE o.uid=c.cus_id) AS pay_fee , (SELECT SUM(o.`pay_fee`) FROM yd_order o WHERE FROM_UNIXTIME(o.`ctime`,'%Y-%m')='2016-06' AND o.uid=c.cus_id) AS pay_fee_m , (SELECT SUM(o.`pay_fee`) FROM yd_order o WHERE FROM_UNIXTIME(o.`ctime`,'%Y')='2016' AND o.uid=c.cus_id) AS pay_fee_y , (SELECT COUNT(*) FROM yd_order o WHERE FROM_UNIXTIME(o.`ctime`,'%Y')='2016' AND o.uid=c.cus_id) AS order_num_y, (SELECT SUM(s.`money`) FROM `yd_surplus_log` s WHERE FROM_UNIXTIME(s.`ctime`,'%Y-%m')='2016-06' AND s.user_id=c.cus_id) AS money_m, (SELECT SUM(s.`money`) FROM `yd_surplus_log` s WHERE FROM_UNIXTIME(s.`ctime`,'%Y')='2016' AND s.user_id=c.cus_id) AS money_y FROM `yd_customer` c