CREATETABLE`taobao`(`UID`int(11)NOTNULLAUTO_INCREMENTCOMMENT'唯一自增ID',`A2`varchar(30)NOTNULLCOMMENT'买家会员名',`A23`datetimeNOTNULLDEFAULT'0000-00-0000:00:00'COMMENT'...
CREATE TABLE `taobao` (
`UID` int(11) NOT NULL AUTO_INCREMENT COMMENT '唯一自增ID',
`A2` varchar(30) NOT NULL COMMENT '买家会员名',
`A23` datetime NOT NULL DEFAULT '0000-00-00 00:00:00' COMMENT '订单付款时间',
`A26` varchar(50) NOT NULL DEFAULT '' COMMENT '物流单号',
`JF` float(12,2) NOT NULL DEFAULT '0.00' COMMENT '会员积分',
PRIMARY KEY (`UID`)
) ENGINE=MyISAM DEFAULT CHARSET=gbk COMMENT='天猫采集表' AUTO_INCREMENT=5 ;
INSERT INTO `taobao` (`UID`, `A2`, `A23`, `A26`, `JF`) VALUES
(1, 'A2', '2017-09-29 19:15:00', 'A26', 1.00),
(2, 'A2', '2017-09-29 08:00:00', 'A26', 11.00),
(3, 'A2', '2017-09-20 00:00:00', 'A26a', 1.00),
(4, 'A3', '2017-09-20 00:00:00', 'A26b', 11.00);
SSELECT UID,A2,COUNT(*),SUM(JF) FROM taobao GROUP BY LEFT(A23,8),A2 ORDER BY a23 ASC
我用这个方法可以合并了,可是COUNT得出来的值是3笔,我想实现A2与2017-09-29先合并为1笔,然后再A2合并,数值应该为2笔才对,请教如何实现
展开