根据商户 ID 分组,同时统计出order_type = 1消费金额money和order_type = 2提现金额money
表结构
DROP TABLE IF EXISTS `store_money_record`;
CREATE TABLE `store_money_record` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`order_no` char(40) NOT NULL,
`store_id` int(11) NOT NULL DEFAULT '0',
`money` decimal(10,2) DEFAULT '0.00',
`content` char(60) NOT NULL,
`type` tinyint(1) NOT NULL DEFAULT '0',
`order_id` int(11) DEFAULT '0',
`order_type` tinyint(1) DEFAULT '0',
`create_time` int(11) DEFAULT NULL,
`update_time` int(11) DEFAULT NULL,
`delete_time` int(11) DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `order_no` (`order_no`),
KEY `idx_delete_time` (`delete_time`),
KEY `idx_store_id` (`store_id`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;