select * from tbl_name procedure analyse();
select * from tbl_name procedure analyse(16,256);
创建客户每天的消费记录:
Create Table: CREATE TABLE `session` (
`cust_id` varchar(10) DEFAULT NULL, `cust_amount` decimal(16,2) DEFAULT NULL, `cust_date` date DEFAULT NULL, `cust_ip` varchar(20) DEFAULT NULL) ENGINE=InnoDB DEFAULT CHARSET=utf8;最近一周客户消费的总金额和近一周不同时段用户的消费总金额
select sum(cust_amount) from session where cust_date>adddate(now(),-7);
创建中间临时表
Create Table: CREATE TABLE `tmp_session` (
`cust_id` varchar(10) DEFAULT NULL, `cust_amount` decimal(16,2) DEFAULT NULL, `cust_date` date DEFAULT NULL, `cust_ip` varchar(20) DEFAULT NULL) ENGINE=InnoDB DEFAULT CHARSET=utf8insert into session values(3,300,'2013-1-7','192.168.1.1');